Skip to content

Commit

Permalink
Merge pull request #695 from gzliudan/fix-sa1012
Browse files Browse the repository at this point in the history
fix staticcheck warning SA1012: pass nil Context to function
  • Loading branch information
gzliudan authored Oct 25, 2024
2 parents b68b9c6 + dd6822b commit acb973a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions contracts/trc21issuer/trc21issuer_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package trc21issuer

import (
"context"
"math/big"
"testing"

Expand Down Expand Up @@ -60,7 +61,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
contractBackend.Commit()

//check trc21 SMC balance
balance, err := contractBackend.BalanceAt(nil, trc21IssuerAddr, nil)
balance, err := contractBackend.BalanceAt(context.TODO(), trc21IssuerAddr, nil)
if err != nil || balance.Cmp(minApply) != 0 {
t.Fatal("can't get balance in trc21Issuer SMC: ", err, "got", balance, "wanted", minApply)
}
Expand All @@ -78,7 +79,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
t.Fatal("can't execute transfer in tr20: ", err)
}
contractBackend.Commit()
receipt, err := contractBackend.TransactionReceipt(nil, tx.Hash())
receipt, err := contractBackend.TransactionReceipt(context.TODO(), tx.Hash())
if err != nil {
t.Fatal("can't transaction's receipt ", err, "hash", tx.Hash())
}
Expand All @@ -100,7 +101,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
t.Fatal("check balance token fee in smart contract: got", balanceIssuerFee, "wanted", remainFee)
}
//check trc21 SMC balance
balance, err = contractBackend.BalanceAt(nil, trc21IssuerAddr, nil)
balance, err = contractBackend.BalanceAt(context.TODO(), trc21IssuerAddr, nil)
if err != nil || balance.Cmp(remainFee) != 0 {
t.Fatal("can't get balance token fee in smart contract: ", err, "got", balanceIssuerFee, "wanted", remainFee)
}
Expand Down Expand Up @@ -130,7 +131,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
t.Fatal("check balance after fail transfer in tr20: ", err, "get", balance, "wanted", remainAirDrop)
}

receipt, err = contractBackend.TransactionReceipt(nil, tx.Hash())
receipt, err = contractBackend.TransactionReceipt(context.TODO(), tx.Hash())
if err != nil {
t.Fatal("can't transaction's receipt ", err, "hash", tx.Hash())
}
Expand All @@ -142,7 +143,7 @@ func TestFeeTxWithTRC21Token(t *testing.T) {
t.Fatal("can't get balance token fee in smart contract: ", err, "got", balanceIssuerFee, "wanted", remainFee)
}
//check trc21 SMC balance
balance, err = contractBackend.BalanceAt(nil, trc21IssuerAddr, nil)
balance, err = contractBackend.BalanceAt(context.TODO(), trc21IssuerAddr, nil)
if err != nil || balance.Cmp(remainFee) != 0 {
t.Fatal("can't get balance token fee in smart contract: ", err, "got", balanceIssuerFee, "wanted", remainFee)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3442,14 +3442,14 @@ func GetSignersFromBlocks(b Backend, blockNumber uint64, blockHash common.Hash,
limitNumber = currentNumber
}
for i := blockNumber + 1; i <= limitNumber; i++ {
header, err := b.HeaderByNumber(nil, rpc.BlockNumber(i))
header, err := b.HeaderByNumber(context.TODO(), rpc.BlockNumber(i))
if err != nil {
return addrs, err
}
if header == nil {
return addrs, errors.New("nil header in GetSignersFromBlocks")
}
blockData, err := b.BlockByNumber(nil, rpc.BlockNumber(i))
blockData, err := b.BlockByNumber(context.TODO(), rpc.BlockNumber(i))
if err != nil {
return addrs, err
}
Expand Down

0 comments on commit acb973a

Please sign in to comment.