Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ta0li committed Jan 4, 2022
1 parent 2ac04ef commit 90810ed
Show file tree
Hide file tree
Showing 28 changed files with 188 additions and 168 deletions.
4 changes: 2 additions & 2 deletions app/node/test/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func CreateBootstrapMiner(ctx context.Context, t *testing.T, seed *ChainSeed, ch
WithBuilderOpt(node.MonkeyPatchSetProofTypeOption(constants.DevRegisteredSealProof)).
Build(ctx)

addr := seed.GiveKey(t, bootstrapMiner, 0)
addr := seed.GiveKey(ctx, t, bootstrapMiner, 0)
err := bootstrapMiner.ConfigModule().API().ConfigSet(ctx, "walletModule.defaultAddress", addr.String())
require.NoError(t, err)

Expand All @@ -60,7 +60,7 @@ func CreateBootstrapMiner(ctx context.Context, t *testing.T, seed *ChainSeed, ch
}

func initNodeGenesisMiner(ctx context.Context, t *testing.T, nd *node.Node, seed *ChainSeed, minerIdx int) (address.Address, address.Address, error) {
seed.GiveKey(t, nd, minerIdx)
seed.GiveKey(ctx, t, nd, minerIdx)
miner, owner := seed.GiveMiner(t, nd, 0)

return miner, owner, nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/address_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAddressNewAndList(t *testing.T) {
addrs := make([]address.Address, 10)
var err error
for i := 0; i < 10; i++ {
addrs[i], err = n.Wallet().API().WalletNewAddress(address.SECP256K1)
addrs[i], err = n.Wallet().API().WalletNewAddress(ctx, address.SECP256K1)
require.NoError(t, err)
}

Expand All @@ -54,7 +54,7 @@ func TestWalletBalance(t *testing.T) {
n, cmdClient, done := builder.BuildAndStartAPI(ctx)
defer done()

addr, err := n.Wallet().API().WalletNewAddress(address.SECP256K1)
addr, err := n.Wallet().API().WalletNewAddress(ctx, address.SECP256K1)
require.NoError(t, err)

t.Log("[success] not found, zero")
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestWalletExportImportRoundTrip(t *testing.T) {
n, cmdClient, done := builder.BuildAndStartAPI(ctx)
defer done()

addr, err := n.Wallet().API().WalletNewAddress(address.SECP256K1)
addr, err := n.Wallet().API().WalletNewAddress(ctx, address.SECP256K1)
require.NoError(t, err)

// ./venus wallet ls
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ require (
github.com/jstemmer/go-junit-report v0.9.1
github.com/libp2p/go-eventbus v0.2.1
github.com/libp2p/go-libp2p v0.17.0
github.com/libp2p/go-libp2p-circuit v0.4.0
github.com/libp2p/go-libp2p-core v0.13.0
github.com/libp2p/go-libp2p-kad-dht v0.15.0
github.com/libp2p/go-libp2p-mplex v0.4.1
Expand Down
12 changes: 6 additions & 6 deletions pkg/chain/reorg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ func TestReorgDiffSubset(t *testing.T) {
// This function returns the forked head, the main head and the common ancestor.
func getForkOldNewCommon(ctx context.Context, t *testing.T, builder *chain.Builder, a, b, c int) (*types.TipSet, *types.TipSet, *types.TipSet) {
// Add "a" tipsets to the head of the chainStore.
commonHead := builder.AppendManyOn(a, types.UndefTipSet)
commonHead := builder.AppendManyOn(ctx, a, types.UndefTipSet)
oldHead := commonHead

if c > 0 {
oldHead = builder.AppendManyOn(c, commonHead)
oldHead = builder.AppendManyOn(ctx, c, commonHead)
}
newHead := builder.AppendManyOn(b, commonHead)
newHead := builder.AppendManyOn(ctx, b, commonHead)
return oldHead, newHead, commonHead
}

Expand All @@ -88,9 +88,9 @@ func getForkOldNewCommon(ctx context.Context, t *testing.T, builder *chain.Build
// consists of this single block and another block together forming a tipset
// that is a superset of the forked head.
func getSubsetOldNewCommon(ctx context.Context, t *testing.T, builder *chain.Builder, a int) (*types.TipSet, *types.TipSet, *types.TipSet) {
commonHead := builder.AppendManyBlocksOnBlocks(a)
block1 := builder.AppendBlockOnBlocks(commonHead)
block2 := builder.AppendBlockOnBlocks(commonHead)
commonHead := builder.AppendManyBlocksOnBlocks(ctx, a)
block1 := builder.AppendBlockOnBlocks(ctx, commonHead)
block2 := builder.AppendBlockOnBlocks(ctx, commonHead)

oldHead := testhelpers.RequireNewTipSet(t, block1)
superset := testhelpers.RequireNewTipSet(t, block1, block2)
Expand Down
2 changes: 1 addition & 1 deletion pkg/chain/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newChainStore(r repo.Repo, genTS *types.TipSet) *CborBlockStore {
// requirePutTestChain puts the count tipsets preceding head in the source to
// the input chain store.
func requirePutTestChain(ctx context.Context, t *testing.T, cborStore *CborBlockStore, head types.TipSetKey, source *chain.Builder, count int) {
tss := source.RequireTipSets(head, count)
tss := source.RequireTipSets(ctx, head, count)
for _, ts := range tss {
tsas := &chain.TipSetMetadata{
TipSet: ts,
Expand Down
6 changes: 3 additions & 3 deletions pkg/chainsync/syncer/syncer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func TestLoadFork(t *testing.T) {

require.NoError(t, err)

base := builder.AppendManyOn(3, genesis)
left := builder.AppendManyOn(4, base)
right := builder.AppendManyOn(3, base)
base := builder.AppendManyOn(ctx, 3, genesis)
left := builder.AppendManyOn(ctx, 4, base)
right := builder.AppendManyOn(ctx, 3, base)

leftTarget := &types.Target{
Base: nil,
Expand Down
4 changes: 2 additions & 2 deletions pkg/chainsync/syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func TestSubsetParent(t *testing.T) {
assert.NoError(t, s.HandleNewTipSet(ctx, target3))

// A full parent also works fine: {C1, C2} -> D1
tipD1OnC1C2 := builder.AppendOn(tipC1C2, 1)
tipD1OnC1C2 := builder.AppendOn(ctx, tipC1C2, 1)
target4 := &syncTypes.Target{
Base: nil,
Current: nil,
Expand Down Expand Up @@ -557,7 +557,7 @@ func TestStoresMessageReceipts(t *testing.T) {
}
assert.NoError(t, syncer.HandleNewTipSet(ctx, target1))

receiptsCid, err := builder.Store().GetTipSetReceiptsRoot(t1)
receiptsCid, err := builder.Store().GetTipSetReceiptsRoot(ctx, t1)

require.NoError(t, err)

Expand Down
18 changes: 9 additions & 9 deletions pkg/discovery/hello_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func TestHelloHandshake(t *testing.T) {
genesisA := builder.Genesis()
store := builder.Store()
mstore := builder.Mstore()
heavy1 := builder.AppendOn(genesisA, 1)
heavy2 := builder.AppendOn(heavy1, 1)
heavy1 := builder.AppendOn(ctx, genesisA, 1)
heavy2 := builder.AppendOn(ctx, heavy1, 1)

msc1, msc2 := new(mockHelloCallback), new(mockHelloCallback)
hg1, hg2 := &mockHeaviestGetter{heavy1}, &mockHeaviestGetter{heavy2}
Expand Down Expand Up @@ -117,11 +117,11 @@ func TestHelloBadGenesis(t *testing.T) {
store := builder.Store()
mstore := builder.Mstore()

genesisA := builder.AppendOn(types.UndefTipSet, 1)
genesisB := builder.AppendOn(types.UndefTipSet, 1)
genesisA := builder.AppendOn(ctx, types.UndefTipSet, 1)
genesisB := builder.AppendOn(ctx, types.UndefTipSet, 1)

heavy1 := builder.AppendOn(genesisA, 1)
heavy2 := builder.AppendOn(heavy1, 1)
heavy1 := builder.AppendOn(ctx, genesisA, 1)
heavy2 := builder.AppendOn(ctx, heavy1, 1)

msc1, msc2 := new(mockHelloCallback), new(mockHelloCallback)
hg1, hg2 := &mockHeaviestGetter{heavy1}, &mockHeaviestGetter{heavy2}
Expand Down Expand Up @@ -164,9 +164,9 @@ func TestHelloMultiBlock(t *testing.T) {
genesisTipset := builder.Genesis()
assert.Equal(t, 1, genesisTipset.Len())

heavy1 := builder.AppendOn(genesisTipset, 3)
heavy1 = builder.AppendOn(heavy1, 3)
heavy2 := builder.AppendOn(heavy1, 3)
heavy1 := builder.AppendOn(ctx, genesisTipset, 3)
heavy1 = builder.AppendOn(ctx, heavy1, 3)
heavy2 := builder.AppendOn(ctx, heavy1, 3)

msc1, msc2 := new(mockHelloCallback), new(mockHelloCallback)
hg1, hg2 := &mockHeaviestGetter{heavy1}, &mockHeaviestGetter{heavy2}
Expand Down
2 changes: 1 addition & 1 deletion pkg/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (fcs *fakeCS) ChainGetPath(ctx context.Context, from, to types.TipSetKey) (
}

// copied from the chainstore
revert, apply, err := chain.ReorgOps(func(tsk types.TipSetKey) (*types.TipSet, error) {
revert, apply, err := chain.ReorgOps(func(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error) {
return fcs.ChainGetTipSet(ctx, tsk)
}, fromTS, toTS)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/market/fundmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (fm *FundManager) Start(ctx context.Context) error {
// - in State() only load addresses with in-progress messages
// - load the others just-in-time from getFundedAddress
// - delete(fm.fundedAddrs, addr) when the queue has been processed
return fm.str.forEach(func(state *FundedAddressState) {
return fm.str.forEach(ctx, func(state *FundedAddressState) {
fa := newFundedAddress(fm, state.Addr)
fa.state = state
fm.fundedAddrs[fa.state.Addr] = fa
Expand Down
19 changes: 12 additions & 7 deletions pkg/market/fundmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ func TestFundManagerReserveByWallet(t *testing.T) {
s := setup(t)
defer s.fm.Stop()

walletAddrA, err := s.wllt.NewAddress(address.SECP256K1)
ctx := context.Background()
walletAddrA, err := s.wllt.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)
walletAddrB, err := s.wllt.NewAddress(address.SECP256K1)
walletAddrB, err := s.wllt.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)

// Wait until all the reservation requests are queued up
Expand Down Expand Up @@ -400,9 +401,11 @@ func TestFundManagerWithdrawByWallet(t *testing.T) {
tf.UnitTest(t)
s := setup(t)
defer s.fm.Stop()
walletAddrA, err := s.wllt.NewAddress(address.SECP256K1)

ctx := context.Background()
walletAddrA, err := s.wllt.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)
walletAddrB, err := s.wllt.NewAddress(address.SECP256K1)
walletAddrB, err := s.wllt.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)

// Reserve 10
Expand Down Expand Up @@ -510,6 +513,8 @@ func TestFundManagerRestart(t *testing.T) {
s := setup(t)
defer s.fm.Stop()

ctx := context.Background()

acctAddr2 := tutils.NewActorAddr(t, "addr2")

// Address 1: Reserve 10
Expand Down Expand Up @@ -537,7 +542,7 @@ func TestFundManagerRestart(t *testing.T) {
// Restart
mockAPIAfter := s.mockAPI
fmAfter := newFundManager(mockAPIAfter, s.ds)
err = fmAfter.Start()
err = fmAfter.Start(ctx)
require.NoError(t, err)

amt3 := abi.NewTokenAmount(9)
Expand Down Expand Up @@ -628,11 +633,11 @@ func setup(t *testing.T) *scaffold {
ctx := context.Background()
t.Log("create a backend")
ds := datastore.NewMapDatastore()
fs, err := wallet.NewDSBackend(ds, config.TestPassphraseConfig(), wallet.TestPassword)
fs, err := wallet.NewDSBackend(ctx, ds, config.TestPassphraseConfig(), wallet.TestPassword)
assert.NoError(t, err)
t.Log("create a wallet with a single backend")
wllt := wallet.New(fs)
walletAddr, err := wllt.NewAddress(address.SECP256K1)
walletAddr, err := wllt.NewAddress(ctx, address.SECP256K1)
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/market/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func (ps *Store) save(ctx context.Context, state *FundedAddressState) error {

// get the state for the given address
// nolint
func (ps *Store) get(addr address.Address) (*FundedAddressState, error) {
func (ps *Store) get(ctx context.Context, addr address.Address) (*FundedAddressState, error) {
k := dskeyForAddr(addr)

data, err := ps.ds.Get(k)
data, err := ps.ds.Get(ctx, k)
if err != nil {
return nil, err
}
Expand All @@ -59,8 +59,8 @@ func (ps *Store) get(addr address.Address) (*FundedAddressState, error) {
}

// forEach calls iter with each address in the datastore
func (ps *Store) forEach(iter func(*FundedAddressState)) error {
res, err := ps.ds.Query(dsq.Query{Prefix: dsKeyAddr})
func (ps *Store) forEach(ctx context.Context, iter func(*FundedAddressState)) error {
res, err := ps.ds.Query(ctx, dsq.Query{Prefix: dsKeyAddr})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/messagepool/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func saveConfig(ctx context.Context, cfg *MpoolConfig, ds repo.Datastore) error
if err != nil {
return err
}
return ds.Put(ctx, ConfigKey, cfgBytes)
return ds.Put(ctx, ConfigKey, cfgBytes)
}

func (mp *MessagePool) GetConfig() *MpoolConfig {
Expand Down
10 changes: 5 additions & 5 deletions pkg/messagepool/messagesigner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ func TestMessageSignerSignMessage(t *testing.T) {

ctx := context.Background()
r := repo.NewInMemoryRepo()
backend, err := wallet.NewDSBackend(r.WalletDatastore(), r.Config().Wallet.PassphraseConfig, wallet.TestPassword)
backend, err := wallet.NewDSBackend(ctx, r.WalletDatastore(), r.Config().Wallet.PassphraseConfig, wallet.TestPassword)
assert.NoError(t, err)

w := wallet.New(backend)

from1, err := w.NewAddress(address.SECP256K1)
from1, err := w.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)
from2, err := w.NewAddress(address.SECP256K1)
from2, err := w.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)
to1, err := w.NewAddress(address.SECP256K1)
to1, err := w.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)
to2, err := w.NewAddress(address.SECP256K1)
to2, err := w.NewAddress(ctx, address.SECP256K1)
require.NoError(t, err)

type msgSpec struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/messagepool/repub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ func TestRepubMessages(t *testing.T) {
}

// the actors
ctx := context.Background()
w1 := newWallet(t)
a1, err := w1.NewAddress(address.SECP256K1)
a1, err := w1.NewAddress(ctx, address.SECP256K1)
if err != nil {
t.Fatal(err)
}

w2 := newWallet(t)
a2, err := w2.NewAddress(address.SECP256K1)
a2, err := w2.NewAddress(ctx, address.SECP256K1)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/messagepool/selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ func TestPriorityMessageSelection2(t *testing.T) {
}

w2 := newWallet(t)
a2, err := w2.NewAddress(context.Background(),address.SECP256K1)
a2, err := w2.NewAddress(context.Background(), address.SECP256K1)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func newEndpoint(t *testing.T, port int) endpoint {
libp2p.Identity(priv),
}

basicHost, err := libp2p.New(context.Background(), opts...)
basicHost, err := libp2p.New(opts...)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/net/blocksub/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func TestBlockTopicValidator(t *testing.T) {
builder := chain.NewBuilder(t, address.Undef)
pid1 := th.RequireIntPeerID(t, 1)

goodBlk := builder.BuildOnBlock(nil, func(b *chain.BlockBuilder) {})
badBlk := builder.BuildOnBlock(nil, func(b *chain.BlockBuilder) {
goodBlk := builder.BuildOnBlock(ctx, nil, func(b *chain.BlockBuilder) {})
badBlk := builder.BuildOnBlock(ctx, nil, func(b *chain.BlockBuilder) {
b.IncHeight(1)
})

Expand Down
Loading

0 comments on commit 90810ed

Please sign in to comment.