Skip to content

Commit

Permalink
fix broken test due to incorrect nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
attente committed Mar 4, 2025
1 parent 5660e79 commit b7d9c1d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
13 changes: 0 additions & 13 deletions estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,16 +829,3 @@ func V3Simulate(provider *ethrpc.Provider, wallet common.Address, transactions T
func Simulate(provider *ethrpc.Provider, wallet common.Address, transactions Transactions, block string, overrides map[common.Address]*CallOverride) ([]SimulatorResult, error) {
return V3Simulate(provider, wallet, transactions, block, overrides)
}

func RandomNonceV3() *big.Int {
// Generate a random space using current time nanoseconds
space := big.NewInt(int64(time.Now().Nanosecond()))

// Ensure space is within 15 bytes (120 bits) as per v3 requirements
maxSpace := new(big.Int)
maxSpace.SetString("ffffffffffffffffffffffffffffff", 16)
space.Mod(space, maxSpace)

// For v3, we directly use the space as the nonce since v3 has different nonce handling
return space
}
8 changes: 0 additions & 8 deletions estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,6 @@ func TestEstimateSequenceMultipleSigners(t *testing.T) {
&sequence.Transaction{
To: callmockContract.Address,
Data: calldata,
Nonce: testChain.RandomNonceV3(),
},
}

Expand Down Expand Up @@ -1853,7 +1852,6 @@ func TestEstimateIssue5367MultipleSignersTime(t *testing.T) {
&sequence.Transaction{
To: callmockContract.Address,
Data: calldata,
Nonce: testChain.RandomNonceV3(),
},
}

Expand All @@ -1868,9 +1866,3 @@ func TestEstimateIssue5367MultipleSignersTime(t *testing.T) {
}
})
}

func TestRandomNonceV3(t *testing.T) {
nonce := sequence.RandomNonceV3()

assert.True(t, nonce.Cmp(big.NewInt(0)) >= 0)
}
11 changes: 0 additions & 11 deletions testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,17 +583,6 @@ func (c *TestChain) RandomNonce() *big.Int {
return encoded
}

func (c *TestChain) RandomNonceV3() *big.Int {
// Generate a random space using current time nanoseconds
space := big.NewInt(int64(time.Now().Nanosecond()))

// Ensure space is within 15 bytes (120 bits) as per v3 requirements
maxSpace := new(big.Int).Lsh(big.NewInt(1), 120) // 15 bytes = 120 bits
space.Mod(space, maxSpace)

return space
}

// ... existing code ...
func (c *TestChain) V1DummySequenceWallet(seed uint64, optSkipDeploy ...bool) (*sequence.Wallet[core.WalletConfig], error) {
// Generate a single-owner sequence wallet based on a private key generated from seed above
Expand Down

0 comments on commit b7d9c1d

Please sign in to comment.