refactor: convert paych to kit2
This commit is contained in:
parent
ac67e466ec
commit
7b00b1828b
@ -30,5 +30,5 @@ func SendFunds(ctx context.Context, t *testing.T, sender TestFullNode, recipient
|
|||||||
res, err := sender.StateWaitMsg(ctx, sm.Cid(), 3, api.LookbackNoLimit, true)
|
res, err := sender.StateWaitMsg(ctx, sm.Cid(), 3, api.LookbackNoLimit, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 0, res.Receipt.ExitCode, "did not successfully send funds")
|
require.EqualValues(t, 0, res.Receipt.ExitCode, "did not successfully send funds")
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -24,36 +23,30 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/events"
|
"github.com/filecoin-project/lotus/chain/events"
|
||||||
"github.com/filecoin-project/lotus/chain/events/state"
|
"github.com/filecoin-project/lotus/chain/events/state"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/itests/kit2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPaymentChannelsAPI(t *testing.T) {
|
func TestPaymentChannelsAPI(t *testing.T) {
|
||||||
kit.QuietMiningLogs()
|
kit2.QuietMiningLogs()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
n, sn := kit.MockMinerBuilder(t, kit.TwoFull, kit.OneMiner)
|
blockTime := 5 * time.Millisecond
|
||||||
|
|
||||||
paymentCreator := n[0]
|
var (
|
||||||
paymentReceiver := n[1]
|
paymentCreator kit2.TestFullNode
|
||||||
miner := sn[0]
|
paymentReceiver kit2.TestFullNode
|
||||||
|
miner kit2.TestMiner
|
||||||
|
)
|
||||||
|
|
||||||
// get everyone connected
|
//n, sn := kit2.MockMinerBuilder(t, kit2.TwoFull, kit2.OneMiner)
|
||||||
addrs, err := paymentCreator.NetAddrsListen(ctx)
|
ens := kit2.NewEnsemble(t, kit2.MockProofs()).
|
||||||
if err != nil {
|
FullNode(&paymentCreator).
|
||||||
t.Fatal(err)
|
FullNode(&paymentReceiver).
|
||||||
}
|
Miner(&miner, &paymentCreator).
|
||||||
|
Start().
|
||||||
if err := paymentReceiver.NetConnect(ctx, addrs); err != nil {
|
InterconnectAll()
|
||||||
t.Fatal(err)
|
bms := ens.BeginMining(blockTime, &miner)
|
||||||
}
|
bm := bms[0]
|
||||||
|
|
||||||
if err := miner.NetConnect(ctx, addrs); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// start mining blocks
|
|
||||||
bm := kit.NewBlockMiner(t, miner)
|
|
||||||
bm.MineBlocks(ctx, 5*time.Millisecond)
|
|
||||||
t.Cleanup(bm.Stop)
|
|
||||||
|
|
||||||
// send some funds to register the receiver
|
// send some funds to register the receiver
|
||||||
receiverAddr, err := paymentReceiver.WalletNew(ctx, types.KTSecp256k1)
|
receiverAddr, err := paymentReceiver.WalletNew(ctx, types.KTSecp256k1)
|
||||||
@ -61,7 +54,7 @@ func TestPaymentChannelsAPI(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
kit.SendFunds(ctx, t, paymentCreator, receiverAddr, abi.NewTokenAmount(1e18))
|
kit2.SendFunds(ctx, t, paymentCreator, receiverAddr, abi.NewTokenAmount(1e18))
|
||||||
|
|
||||||
// setup the payment channel
|
// setup the payment channel
|
||||||
createrAddr, err := paymentCreator.WalletDefaultAddress(ctx)
|
createrAddr, err := paymentCreator.WalletDefaultAddress(ctx)
|
||||||
@ -263,12 +256,9 @@ func TestPaymentChannelsAPI(t *testing.T) {
|
|||||||
if !delta.Equals(abi.NewTokenAmount(expectedRefund)) {
|
if !delta.Equals(abi.NewTokenAmount(expectedRefund)) {
|
||||||
t.Fatalf("did not send correct funds from creator: expected %d, got %d", expectedRefund, delta)
|
t.Fatalf("did not send correct funds from creator: expected %d, got %d", expectedRefund, delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// shut down mining
|
|
||||||
bm.Stop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForBlocks(ctx context.Context, t *testing.T, bm *kit.BlockMiner, paymentReceiver kit.TestFullNode, receiverAddr address.Address, count int) {
|
func waitForBlocks(ctx context.Context, t *testing.T, bm *kit2.BlockMiner, paymentReceiver kit2.TestFullNode, receiverAddr address.Address, count int) {
|
||||||
// We need to add null blocks in batches, if we add too many the chain can't sync
|
// We need to add null blocks in batches, if we add too many the chain can't sync
|
||||||
batchSize := 60
|
batchSize := 60
|
||||||
for i := 0; i < count; i += batchSize {
|
for i := 0; i < count; i += batchSize {
|
||||||
@ -297,7 +287,7 @@ func waitForBlocks(ctx context.Context, t *testing.T, bm *kit.BlockMiner, paymen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForMessage(ctx context.Context, t *testing.T, paymentCreator kit.TestFullNode, msgCid cid.Cid, duration time.Duration, desc string) *api.MsgLookup {
|
func waitForMessage(ctx context.Context, t *testing.T, paymentCreator kit2.TestFullNode, msgCid cid.Cid, duration time.Duration, desc string) *api.MsgLookup {
|
||||||
ctx, cancel := context.WithTimeout(ctx, duration)
|
ctx, cancel := context.WithTimeout(ctx, duration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user