Skip to content

Commit ff78ccc

Browse files
committed
grab block height from rpc client
1 parent 4612e2a commit ff78ccc

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

core/retry_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ func TestBatchesStateWriter(t *testing.T) {
826826
}
827827

828828
func TestBalanceAt(t *testing.T) {
829-
cmd, _, err := SetupAnvil(8545)
829+
cmd, client, err := SetupAnvil(8545)
830830
if err != nil {
831831
t.Errorf("Error setting up Anvil: %s\n", err)
832832
}
@@ -837,9 +837,14 @@ func TestBalanceAt(t *testing.T) {
837837
return
838838
}
839839
aggregator_address := common.HexToAddress("0x0")
840-
blockHeight := big.NewInt(13)
840+
// Fetch the latest block number
841+
blockNumberUint64, err := client.BlockNumber(context.Background())
842+
blockNumber := new(big.Int).SetUint64(blockNumberUint64)
843+
if err != nil {
844+
log.Fatal(err)
845+
}
841846

842-
balance_func := chainio.BalanceAt(avsWriter, context.Background(), aggregator_address, blockHeight)
847+
balance_func := chainio.BalanceAt(avsWriter, context.Background(), aggregator_address, blockNumber)
843848
_, err = balance_func()
844849
assert.Nil(t, err)
845850

@@ -848,7 +853,7 @@ func TestBalanceAt(t *testing.T) {
848853
return
849854
}
850855

851-
balance_func = chainio.BalanceAt(avsWriter, context.Background(), aggregator_address, blockHeight)
856+
balance_func = chainio.BalanceAt(avsWriter, context.Background(), aggregator_address, blockNumber)
852857
_, err = balance_func()
853858
assert.NotNil(t, err)
854859
if _, ok := err.(retry.PermanentError); ok {
@@ -865,7 +870,7 @@ func TestBalanceAt(t *testing.T) {
865870
t.Errorf("Error setting up Anvil: %s\n", err)
866871
}
867872

868-
balance_func = chainio.BalanceAt(avsWriter, context.Background(), aggregator_address, blockHeight)
873+
balance_func = chainio.BalanceAt(avsWriter, context.Background(), aggregator_address, blockNumber)
869874
_, err = balance_func()
870875
assert.Nil(t, err)
871876

0 commit comments

Comments
 (0)