diff --git a/.changeset/slick-pianos-warn.md b/.changeset/slick-pianos-warn.md new file mode 100644 index 00000000000..d02f9dd2ae0 --- /dev/null +++ b/.changeset/slick-pianos-warn.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#bugfix fix block number nil issue in fake evm diff --git a/core/capabilities/fakes/evm_chain.go b/core/capabilities/fakes/evm_chain.go index be18a41da75..a0acd9aa56f 100644 --- a/core/capabilities/fakes/evm_chain.go +++ b/core/capabilities/fakes/evm_chain.go @@ -3,6 +3,7 @@ package fakes import ( "context" "crypto/ecdsa" + "errors" "fmt" "math/big" "strings" @@ -300,12 +301,18 @@ func (fc *FakeEVMChain) FilterLogs(ctx context.Context, metadata commonCap.Reque func (fc *FakeEVMChain) BalanceAt(ctx context.Context, metadata commonCap.RequestMetadata, input *evmcappb.BalanceAtRequest) (*commonCap.ResponseAndMetadata[*evmcappb.BalanceAtReply], error) { fc.eng.Infow("EVM Chain BalanceAt Started", "input", input) + if input == nil { + return nil, errors.New("BalanceAtRequest is nil") + } + // Prepare balance at request address := common.Address(input.Account) - blockNumber := new(big.Int).SetBytes(input.BlockNumber.AbsVal) + + // Convert proto big-int to *big.Int; nil ⇒ latest (handled by geth toBlockNumArg) + blockArg := pb.NewIntFromBigInt(input.BlockNumber) // Get balance at block number - balance, err := fc.gethClient.BalanceAt(ctx, address, blockNumber) + balance, err := fc.gethClient.BalanceAt(ctx, address, blockArg) if err != nil { return nil, err }