Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramtinms committed Sep 17, 2024
1 parent c35bacc commit 067c3ac
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions fvm/evm/emulator/emulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,8 @@ func TestCallingExtraPrecompiles(t *testing.T) {
AddressFunc: func() types.Address {
return addr
},
RequiredGasFunc: func(input []byte) uint64 {
RequiredGasFunc: func(inp []byte) uint64 {
require.Equal(t, input, inp)
return uint64(10)
},
RunFunc: func(inp []byte) ([]byte, error) {
Expand Down Expand Up @@ -1194,14 +1195,15 @@ func TestTransactionTracing(t *testing.T) {
blk, uploader, tracer := blockWithTracer(t, emu)

var txID gethCommon.Hash
var trace json.RawMessage

blockID := flow.Identifier{0x01}
uploaded := make(chan struct{})

uploader.UploadFunc = func(id string, message json.RawMessage) error {
uploaded <- struct{}{}
require.Equal(t, debug.TraceID(txID, blockID), id)
require.NotEmpty(t, message)
require.Equal(t, trace, message)
require.Greater(t, len(message), 0)
return nil
}
Expand All @@ -1223,6 +1225,8 @@ func TestTransactionTracing(t *testing.T) {
require.NoError(t, res.ValidationError)
require.NoError(t, res.VMError)
txID = res.TxHash
trace = tracer.GetResultByTxHash(txID)
require.NotEmpty(t, trace)
tracer.Collect(txID)

testAccount.SetNonce(testAccount.Nonce() + 1)
Expand All @@ -1238,14 +1242,15 @@ func TestTransactionTracing(t *testing.T) {
blk, uploader, tracer := blockWithTracer(t, emu)

var txID gethCommon.Hash
var trace json.RawMessage

uploaded := make(chan struct{})
blockID := flow.Identifier{0x01}

uploader.UploadFunc = func(id string, message json.RawMessage) error {
uploaded <- struct{}{}
require.Equal(t, debug.TraceID(txID, blockID), id)
require.NotEmpty(t, message)
require.Equal(t, trace, message)
require.Greater(t, len(message), 0)
return nil
}
Expand All @@ -1263,6 +1268,8 @@ func TestTransactionTracing(t *testing.T) {
)
requireSuccessfulExecution(t, err, res)
txID = res.TxHash
trace = tracer.GetResultByTxHash(txID)
require.NotEmpty(t, trace)
tracer.WithBlockID(blockID)
tracer.Collect(txID)

Expand All @@ -1279,14 +1286,15 @@ func TestTransactionTracing(t *testing.T) {
blk, uploader, tracer := blockWithTracer(t, emu)

var txID gethCommon.Hash
var trace json.RawMessage

blockID := flow.Identifier{0x02}
uploaded := make(chan struct{})

uploader.UploadFunc = func(id string, message json.RawMessage) error {
uploaded <- struct{}{}
require.Equal(t, debug.TraceID(txID, blockID), id)
require.NotEmpty(t, message)
require.Equal(t, trace, message)
require.Greater(t, len(message), 0)
return nil
}
Expand All @@ -1304,6 +1312,8 @@ func TestTransactionTracing(t *testing.T) {
res, err := blk.RunTransaction(tx)
requireSuccessfulExecution(t, err, res)
txID = res.TxHash
trace = tracer.GetResultByTxHash(txID)
require.NotEmpty(t, trace)
tracer.WithBlockID(blockID)
tracer.Collect(txID)

Expand Down Expand Up @@ -1353,14 +1363,15 @@ func TestTransactionTracing(t *testing.T) {
blk, uploader, tracer := blockWithTracer(t, emu)

var txID gethCommon.Hash
var trace json.RawMessage

blockID := flow.Identifier{0x02}
uploaded := make(chan struct{})

uploader.UploadFunc = func(id string, message json.RawMessage) error {
uploaded <- struct{}{}
require.Equal(t, debug.TraceID(txID, blockID), id)
require.NotEmpty(t, message)
require.Equal(t, trace, message)
require.Greater(t, len(message), 0)
return nil
}
Expand All @@ -1380,6 +1391,8 @@ func TestTransactionTracing(t *testing.T) {
requireSuccessfulExecution(t, err, res)
txID = res.TxHash
tracer.WithBlockID(blockID)
trace = tracer.GetResultByTxHash(txID)
require.NotEmpty(t, trace)
tracer.Collect(txID)

testAccount.SetNonce(testAccount.Nonce() + 1)
Expand Down Expand Up @@ -1443,14 +1456,15 @@ func TestTransactionTracing(t *testing.T) {
blk, uploader, tracer := blockWithTracer(t, emu)

var txID gethCommon.Hash
var trace json.RawMessage

blockID := flow.Identifier{0x02}
uploaded := make(chan struct{})

uploader.UploadFunc = func(id string, message json.RawMessage) error {
uploaded <- struct{}{}
require.Equal(t, debug.TraceID(txID, blockID), id)
require.NotEmpty(t, message)
require.Equal(t, trace, message)
require.Greater(t, len(message), 0)
return nil
}
Expand All @@ -1469,6 +1483,7 @@ func TestTransactionTracing(t *testing.T) {
require.NoError(t, err)
require.Len(t, results, 1)
txID = results[0].TxHash
trace = tracer.GetResultByTxHash(txID)
tracer.WithBlockID(blockID)
tracer.Collect(txID)

Expand Down

0 comments on commit 067c3ac

Please sign in to comment.