MCPcopy Create free account
hub / github.com/DNAProject/DNA / TestConsensusHandle

Function TestConsensusHandle

p2pserver/message/utils/msg_handler_test.go:590–620  ·  view source on GitHub ↗

TestConsensusHandle tests Function ConsensusHandle handling a consensus message

(t *testing.T)

Source from the content-addressed store, hash-verified

588
589// TestConsensusHandle tests Function ConsensusHandle handling a consensus message
590func 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
623func TestNotFoundHandle(t *testing.T) {

Callers

nothing calls this directly

Calls 2

ConsensusHandleFunction · 0.85
GetBlockHashMethod · 0.65

Tested by

no test coverage detected