github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/gossip/evmstore/store_test.go (about) 1 package evmstore 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 "github.com/unicornultrafoundation/go-helios/u2udb/memorydb" 9 "github.com/unicornultrafoundation/go-u2u/core/types" 10 ) 11 12 func cachedStore() *Store { 13 cfg := LiteStoreConfig() 14 15 return NewStore(memorydb.NewProducer(""), cfg) 16 } 17 18 func nonCachedStore() *Store { 19 cfg := StoreConfig{} 20 21 return NewStore(memorydb.NewProducer(""), cfg) 22 } 23 24 func TestStoreSetTx(t *testing.T) { 25 store := cachedStore() 26 27 tx := types.NewTx(&types.LegacyTx{Data: []byte("test")}) 28 29 store.SetTx(tx.Hash(), tx) 30 31 txFromStore := store.GetTx(tx.Hash()) 32 require.Equal(t, tx.Hash(), txFromStore.Hash()) 33 require.Equal(t, tx.Data(), txFromStore.Data()) 34 require.Equal(t, tx.Nonce(), txFromStore.Nonce()) 35 require.Equal(t, tx.Size(), txFromStore.Size()) 36 require.Equal(t, tx.Value(), txFromStore.Value()) 37 require.Equal(t, tx.To(), txFromStore.To()) 38 require.Equal(t, tx.Gas(), txFromStore.Gas()) 39 require.Equal(t, tx.GasPrice(), txFromStore.GasPrice()) 40 }