remove duplicate query in receipts (#273)

* logs tests

* updates

* String()

* remove extra query, add comments

* test fixes

* lint

* lint
This commit is contained in:
Federico Kunze
2020-05-02 21:56:18 -04:00
committed by GitHub
parent 86cd39defb
commit 26d4e968e0
7 changed files with 234 additions and 59 deletions
+27 -4
View File
@@ -20,7 +20,10 @@ import (
const addrHex = "0x756F45E3FA69347A9A973A725E3C98bC4db0b4c1"
var address = ethcmn.HexToAddress(addrHex)
var (
address = ethcmn.HexToAddress(addrHex)
hash = ethcmn.FromHex("0x0d87a3a5f73140f46aac1bf419263e4e94e87c292f25007700ab7f2060e2af68")
)
type KeeperTestSuite struct {
suite.Suite
@@ -42,6 +45,26 @@ func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}
func (suite *KeeperTestSuite) TestTransactionLogs() {
log := &ethtypes.Log{
Address: address,
Data: []byte("log"),
BlockNumber: 10,
}
expLogs := []*ethtypes.Log{log}
err := suite.app.EvmKeeper.SetTransactionLogs(suite.ctx, expLogs, hash)
suite.Require().NoError(err)
suite.app.EvmKeeper.AddLog(suite.ctx, expLogs[0])
logs, err := suite.app.EvmKeeper.GetTransactionLogs(suite.ctx, hash)
suite.Require().NoError(err)
suite.Require().Equal(expLogs, logs)
logs = suite.app.EvmKeeper.AllLogs(suite.ctx)
suite.Require().Equal(expLogs, logs)
}
func (suite *KeeperTestSuite) TestDBStorage() {
// Perform state transitions
suite.app.EvmKeeper.CreateAccount(suite.ctx, address)
@@ -51,8 +74,8 @@ func (suite *KeeperTestSuite) TestDBStorage() {
suite.app.EvmKeeper.SetCode(suite.ctx, address, []byte{0x1})
// Test block hash mapping functionality
suite.app.EvmKeeper.SetBlockHashMapping(suite.ctx, ethcmn.FromHex("0x0d87a3a5f73140f46aac1bf419263e4e94e87c292f25007700ab7f2060e2af68"), 7)
height, err := suite.app.EvmKeeper.GetBlockHashMapping(suite.ctx, ethcmn.FromHex("0x0d87a3a5f73140f46aac1bf419263e4e94e87c292f25007700ab7f2060e2af68"))
suite.app.EvmKeeper.SetBlockHashMapping(suite.ctx, hash, 7)
height, err := suite.app.EvmKeeper.GetBlockHashMapping(suite.ctx, hash)
suite.Require().NoError(err)
suite.Require().Equal(int64(7), height)
@@ -68,7 +91,7 @@ func (suite *KeeperTestSuite) TestDBStorage() {
suite.Require().Equal(suite.app.EvmKeeper.GetState(suite.ctx, address, ethcmn.HexToHash("0x2")), ethcmn.HexToHash("0x3"))
suite.Require().Equal(suite.app.EvmKeeper.GetCode(suite.ctx, address), []byte{0x1})
height, err = suite.app.EvmKeeper.GetBlockHashMapping(suite.ctx, ethcmn.FromHex("0x0d87a3a5f73140f46aac1bf419263e4e94e87c292f25007700ab7f2060e2af68"))
height, err = suite.app.EvmKeeper.GetBlockHashMapping(suite.ctx, hash)
suite.Require().NoError(err)
suite.Require().Equal(height, int64(7))
height, err = suite.app.EvmKeeper.GetBlockHashMapping(suite.ctx, []byte{0x43, 0x32})