-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: eth_getTransactionByHash + eth_getTransactionReceipt fixes #9933
Changes from 7 commits
48b4e75
061e214
645221d
ac39d5c
51c0f1b
2445487
4963c0b
a2af7df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ func TestDeployment(t *testing.T) { | |
// He who writes the second test, shall do that. | ||
// kit.QuietMiningLogs() | ||
|
||
blockTime := 100 * time.Millisecond | ||
// reasonable blocktime so that the tx sits in the mpool for a bit during the test. | ||
// although this is non-deterministic... | ||
blockTime := 1 * time.Second | ||
client, _, ens := kit.EnsembleMinimal( | ||
t, | ||
kit.MockProofs(), | ||
|
@@ -94,17 +96,25 @@ func TestDeployment(t *testing.T) { | |
hash := client.EVM().SubmitTransaction(ctx, &tx) | ||
fmt.Println(hash) | ||
|
||
mpoolTx, err := client.EthGetTransactionByHash(ctx, &hash) | ||
require.NoError(t, err) | ||
|
||
// require that the hashes are identical | ||
require.Equal(t, hash, mpoolTx.Hash) | ||
|
||
// these fields should be nil because the tx hasn't landed on chain. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, let's not play this game, we're inviting flakiness here. Can we just try to lookup the receipt before making these assertions? If found, let's simply skip them (with a log saying that we're doing so). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually a pretty important assertion (we had bugs here before, so want to lock these for regression testing). I'm onboard with deflaking, as long as we don't withdraw coverage we need. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Miners in the itest framework have |
||
require.Nil(t, mpoolTx.BlockNumber) | ||
require.Nil(t, mpoolTx.BlockHash) | ||
require.Nil(t, mpoolTx.TransactionIndex) | ||
|
||
changes, err := client.EthGetFilterChanges(ctx, pendingFilter) | ||
require.NoError(t, err) | ||
require.Len(t, changes.Results, 1) | ||
require.Equal(t, hash.String(), changes.Results[0]) | ||
|
||
time.Sleep(5 * time.Second) | ||
|
||
var receipt *api.EthTxReceipt | ||
for i := 0; i < 10000000000; i++ { | ||
for i := 0; i < 20; i++ { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do need to check that the receipt is null while the transaction hasn't landed on chain -- it's part of the test's coverage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, keep doing that every 500ms, but the cue to stop is StateWaitMsg returning (not "i waited 10 seconds"). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need a timeout for the test (should not let it run indefinitely). We could have a timed context with StateWaitMsg, but at that point we're achieving the same effect as here with more complicated code, so it's a matter of choice. |
||
receipt, err = client.EthGetTransactionReceipt(ctx, hash) | ||
fmt.Println(receipt, err) | ||
if err != nil || receipt == nil { | ||
time.Sleep(500 * time.Millisecond) | ||
continue | ||
|
@@ -113,10 +123,28 @@ func TestDeployment(t *testing.T) { | |
} | ||
require.NoError(t, err) | ||
require.NotNil(t, receipt) | ||
// logs must be an empty array, not a nil value, to avoid tooling compatibility issues | ||
require.Empty(t, receipt.Logs) | ||
// a correctly formed logs bloom, albeit empty, has 256 zeroes | ||
require.Len(t, receipt.LogsBloom, 256) | ||
require.Equal(t, ethtypes.EthBytes(make([]byte, 256)), receipt.LogsBloom) | ||
|
||
// Success. | ||
require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status) | ||
|
||
// Verify that the chain transaction now has new fields set. | ||
chainTx, err := client.EthGetTransactionByHash(ctx, &hash) | ||
require.NoError(t, err) | ||
|
||
// require that the hashes are identical | ||
require.Equal(t, hash, chainTx.Hash) | ||
require.NotNil(t, chainTx.BlockNumber) | ||
require.Greater(t, uint64(*chainTx.BlockNumber), uint64(0)) | ||
require.NotNil(t, chainTx.BlockHash) | ||
require.NotEmpty(t, *chainTx.BlockHash) | ||
require.NotNil(t, chainTx.TransactionIndex) | ||
require.Equal(t, uint64(*chainTx.TransactionIndex), uint64(0)) // only transaction | ||
|
||
// Verify that the deployer is now an account. | ||
client.AssertActorType(ctx, deployer, manifest.EthAccountKey) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider increasing this -- this test isn't really constrained by epochs (needs ~3 epochs), so even if the blocktime were like 5 seconds, it would still finish pretty quickly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus the boot up time for the chain (around 10 epochs).