github.com/MetalBlockchain/subnet-evm@v0.4.9/plugin/evm/message/handler_test.go (about) 1 // (c) 2019-2021, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package message 5 6 import ( 7 "testing" 8 9 "github.com/MetalBlockchain/metalgo/ids" 10 11 "github.com/stretchr/testify/assert" 12 ) 13 14 type CounterHandler struct { 15 Txs int 16 } 17 18 func (h *CounterHandler) HandleTxs(ids.NodeID, TxsGossip) error { 19 h.Txs++ 20 return nil 21 } 22 23 func TestHandleTxs(t *testing.T) { 24 assert := assert.New(t) 25 26 handler := CounterHandler{} 27 msg := TxsGossip{} 28 29 err := msg.Handle(&handler, ids.EmptyNodeID) 30 assert.NoError(err) 31 assert.Equal(1, handler.Txs) 32 } 33 34 func TestNoopHandler(t *testing.T) { 35 assert := assert.New(t) 36 37 handler := NoopMempoolGossipHandler{} 38 39 err := handler.HandleTxs(ids.EmptyNodeID, TxsGossip{}) 40 assert.NoError(err) 41 }