TestInvHandle tests Function InvHandle handling an inventory message
(t *testing.T)
| 719 | |
| 720 | // TestInvHandle tests Function InvHandle handling an inventory message |
| 721 | func TestInvHandle(t *testing.T) { |
| 722 | var testID uint64 |
| 723 | _, testPub, _ := keypair.GenerateKeyPair(keypair.PK_ECDSA, keypair.P256) |
| 724 | key := keypair.SerializePublicKey(testPub) |
| 725 | err := binary.Read(bytes.NewBuffer(key[:8]), binary.LittleEndian, &(testID)) |
| 726 | assert.Nil(t, err) |
| 727 | |
| 728 | remotePeer := peer.NewPeer() |
| 729 | assert.NotNil(t, remotePeer) |
| 730 | remotePeer.UpdateInfo(time.Now(), 1, 12345678, 20336, |
| 731 | testID, 0, 12345, "1.5.2") |
| 732 | remotePeer.Link.SetAddr("127.0.0.1:50010") |
| 733 | |
| 734 | network.AddNbrNode(remotePeer) |
| 735 | |
| 736 | hash := ledger.DefLedger.GetBlockHash(0) |
| 737 | assert.NotEqual(t, hash, common.UINT256_EMPTY) |
| 738 | |
| 739 | buf := bytes.NewBuffer([]byte{}) |
| 740 | hash.Serialize(buf) |
| 741 | invPayload := msgpack.NewInvPayload(common.BLOCK, []common.Uint256{hash}) |
| 742 | buffer := msgpack.NewInv(invPayload) |
| 743 | msg := &types.MsgPayload{ |
| 744 | Id: testID, |
| 745 | Addr: "127.0.0.1:50010", |
| 746 | Payload: buffer, |
| 747 | } |
| 748 | |
| 749 | InvHandle(msg, network, nil) |
| 750 | |
| 751 | network.DelNbrNode(testID) |
| 752 | } |
| 753 | |
| 754 | // TestDisconnectHandle tests Function DisconnectHandle handling a disconnect event |
| 755 | func TestDisconnectHandle(t *testing.T) { |
nothing calls this directly
no test coverage detected