TestConsensusHandle tests Function ConsensusHandle handling a consensus message
(t *testing.T)
| 588 | |
| 589 | // TestConsensusHandle tests Function ConsensusHandle handling a consensus message |
| 590 | func TestConsensusHandle(t *testing.T) { |
| 591 | var testID uint64 |
| 592 | _, testPub, _ := keypair.GenerateKeyPair(keypair.PK_ECDSA, keypair.P256) |
| 593 | key := keypair.SerializePublicKey(testPub) |
| 594 | err := binary.Read(bytes.NewBuffer(key[:8]), binary.LittleEndian, &(testID)) |
| 595 | assert.Nil(t, err) |
| 596 | |
| 597 | hash := ledger.DefLedger.GetBlockHash(0) |
| 598 | assert.NotEqual(t, hash, common.UINT256_EMPTY) |
| 599 | |
| 600 | cpl := &types.ConsensusPayload{ |
| 601 | Version: 1, |
| 602 | PrevHash: hash, |
| 603 | Height: 0, |
| 604 | BookkeeperIndex: 0, |
| 605 | Timestamp: uint32(time.Now().UTC().UnixNano()), |
| 606 | Data: []byte{}, |
| 607 | Owner: testPub, |
| 608 | Signature: []byte{}, |
| 609 | } |
| 610 | |
| 611 | buf := msgpack.NewConsensus(cpl) |
| 612 | |
| 613 | msg := &types.MsgPayload{ |
| 614 | Id: testID, |
| 615 | Addr: "127.0.0.1:50010", |
| 616 | Payload: buf, |
| 617 | } |
| 618 | |
| 619 | ConsensusHandle(msg, network, nil) |
| 620 | } |
| 621 | |
| 622 | // TestNotFoundHandle tests Function NotFoundHandle handling a not found message |
| 623 | func TestNotFoundHandle(t *testing.T) { |
nothing calls this directly
no test coverage detected