cleaner instantiation of lite and gateway nodes + general cleanup.
This commit is contained in:
parent
3ae42d4648
commit
3d8eb374bd
@ -17,5 +17,5 @@ func TestClient(t *testing.T) {
|
|||||||
blockTime := 5 * time.Millisecond
|
blockTime := 5 * time.Millisecond
|
||||||
client, _, ens := kit2.EnsembleMinimal(t, kit2.MockProofs(), kit2.ThroughRPC())
|
client, _, ens := kit2.EnsembleMinimal(t, kit2.MockProofs(), kit2.ThroughRPC())
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
kit2.RunClientTest(t, cli.Commands, *client)
|
kit2.RunClientTest(t, cli.Commands, client)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -45,7 +44,6 @@ func init() {
|
|||||||
// TestGatewayWalletMsig tests that API calls to wallet and msig can be made on a lite
|
// TestGatewayWalletMsig tests that API calls to wallet and msig can be made on a lite
|
||||||
// node that is connected through a gateway to a full API node
|
// node that is connected through a gateway to a full API node
|
||||||
func TestGatewayWalletMsig(t *testing.T) {
|
func TestGatewayWalletMsig(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
|
||||||
kit2.QuietMiningLogs()
|
kit2.QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
blocktime := 5 * time.Millisecond
|
||||||
@ -111,7 +109,6 @@ func TestGatewayWalletMsig(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return lite.MpoolPush(ctx, sm)
|
return lite.MpoolPush(ctx, sm)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +176,6 @@ func TestGatewayWalletMsig(t *testing.T) {
|
|||||||
// TestGatewayMsigCLI tests that msig CLI calls can be made
|
// TestGatewayMsigCLI tests that msig CLI calls can be made
|
||||||
// on a lite node that is connected through a gateway to a full API node
|
// on a lite node that is connected through a gateway to a full API node
|
||||||
func TestGatewayMsigCLI(t *testing.T) {
|
func TestGatewayMsigCLI(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
|
||||||
kit2.QuietMiningLogs()
|
kit2.QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
blocktime := 5 * time.Millisecond
|
||||||
@ -192,7 +188,6 @@ func TestGatewayMsigCLI(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayDealFlow(t *testing.T) {
|
func TestGatewayDealFlow(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
|
||||||
kit2.QuietMiningLogs()
|
kit2.QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
blocktime := 5 * time.Millisecond
|
||||||
@ -200,18 +195,19 @@ func TestGatewayDealFlow(t *testing.T) {
|
|||||||
nodes := startNodesWithFunds(ctx, t, blocktime, maxLookbackCap, maxStateWaitLookbackLimit)
|
nodes := startNodesWithFunds(ctx, t, blocktime, maxLookbackCap, maxStateWaitLookbackLimit)
|
||||||
defer nodes.closer()
|
defer nodes.closer()
|
||||||
|
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
// For these tests where the block time is artificially short, just use
|
// For these tests where the block time is artificially short, just use
|
||||||
// a deal start epoch that is guaranteed to be far enough in the future
|
// a deal start epoch that is guaranteed to be far enough in the future
|
||||||
// so that the deal starts sealing in time
|
// so that the deal starts sealing in time
|
||||||
dealStartEpoch := abi.ChainEpoch(2 << 12)
|
dealStartEpoch := abi.ChainEpoch(2 << 12)
|
||||||
|
|
||||||
dh := kit2.NewDealHarness(t, &nodes.lite, &nodes.miner)
|
dh := kit2.NewDealHarness(t, nodes.lite, nodes.miner)
|
||||||
dealCid, res, _ := dh.MakeOnlineDeal(ctx, 6, false, dealStartEpoch)
|
dealCid, res, _ := dh.MakeOnlineDeal(ctx, 6, false, dealStartEpoch)
|
||||||
dh.PerformRetrieval(ctx, dealCid, res.Root, false)
|
dh.PerformRetrieval(ctx, dealCid, res.Root, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayCLIDealFlow(t *testing.T) {
|
func TestGatewayCLIDealFlow(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
|
||||||
kit2.QuietMiningLogs()
|
kit2.QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
blocktime := 5 * time.Millisecond
|
||||||
@ -223,9 +219,9 @@ func TestGatewayCLIDealFlow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type testNodes struct {
|
type testNodes struct {
|
||||||
lite kit2.TestFullNode
|
lite *kit2.TestFullNode
|
||||||
full kit2.TestFullNode
|
full *kit2.TestFullNode
|
||||||
miner kit2.TestMiner
|
miner *kit2.TestMiner
|
||||||
closer jsonrpc.ClientCloser
|
closer jsonrpc.ClientCloser
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +238,8 @@ func startNodesWithFunds(
|
|||||||
fullWalletAddr, err := nodes.full.WalletDefaultAddress(ctx)
|
fullWalletAddr, err := nodes.full.WalletDefaultAddress(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Create a wallet on the lite node
|
// Get the lite node default wallet address.
|
||||||
liteWalletAddr, err := nodes.lite.WalletNew(ctx, types.KTSecp256k1)
|
liteWalletAddr, err := nodes.lite.WalletDefaultAddress(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Send some funds from the full node to the lite node
|
// Send some funds from the full node to the lite node
|
||||||
@ -263,9 +259,9 @@ func startNodes(
|
|||||||
var closer jsonrpc.ClientCloser
|
var closer jsonrpc.ClientCloser
|
||||||
|
|
||||||
var (
|
var (
|
||||||
full kit2.TestFullNode
|
full *kit2.TestFullNode
|
||||||
|
miner *kit2.TestMiner
|
||||||
lite kit2.TestFullNode
|
lite kit2.TestFullNode
|
||||||
miner kit2.TestMiner
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// - Create one full node and one lite node
|
// - Create one full node and one lite node
|
||||||
@ -273,12 +269,13 @@ func startNodes(
|
|||||||
// - Start full node 2 in lite mode
|
// - Start full node 2 in lite mode
|
||||||
// - Connect lite node -> gateway server -> full node
|
// - Connect lite node -> gateway server -> full node
|
||||||
|
|
||||||
var liteOptBuilder kit2.OptBuilder
|
// create the full node and the miner.
|
||||||
liteOptBuilder = func(nodes []*kit2.TestFullNode) node.Option {
|
var ens *kit2.Ensemble
|
||||||
fullNode := nodes[0]
|
full, miner, ens = kit2.EnsembleMinimal(t, kit2.MockProofs())
|
||||||
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
// Create a gateway server in front of the full node
|
// Create a gateway server in front of the full node
|
||||||
gwapi := gateway.NewNode(fullNode, lookbackCap, stateWaitLookbackLimit)
|
gwapi := gateway.NewNode(full, lookbackCap, stateWaitLookbackLimit)
|
||||||
handler, err := gateway.Handler(gwapi)
|
handler, err := gateway.Handler(gwapi)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -289,22 +286,18 @@ func startNodes(
|
|||||||
gapi, closer, err = client.NewGatewayRPCV1(ctx, "ws://"+srv.Listener.Addr().String()+"/rpc/v1", nil)
|
gapi, closer, err = client.NewGatewayRPCV1(ctx, "ws://"+srv.Listener.Addr().String()+"/rpc/v1", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Provide the gateway API to dependency injection
|
ens.FullNode(&lite,
|
||||||
return node.Override(new(api.Gateway), gapi)
|
kit2.LiteNode(),
|
||||||
}
|
kit2.ThroughRPC(),
|
||||||
|
kit2.ConstructorOpts(
|
||||||
|
node.Override(new(api.Gateway), gapi),
|
||||||
|
),
|
||||||
|
).Start().InterconnectAll()
|
||||||
|
|
||||||
kit2.NewEnsemble(t, kit2.MockProofs()).
|
return &testNodes{lite: &lite, full: full, miner: miner, closer: closer}
|
||||||
FullNode(&full).
|
|
||||||
FullNode(&lite, kit2.LiteNode(), kit2.ThroughRPC(), kit2.AddOptBuilder(liteOptBuilder)).
|
|
||||||
Miner(&miner, &full).
|
|
||||||
Start().
|
|
||||||
InterconnectAll().
|
|
||||||
BeginMining(blocktime)
|
|
||||||
|
|
||||||
return &testNodes{lite: lite, full: full, miner: miner, closer: closer}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendFunds(ctx context.Context, fromNode kit2.TestFullNode, fromAddr address.Address, toAddr address.Address, amt types.BigInt) error {
|
func sendFunds(ctx context.Context, fromNode *kit2.TestFullNode, fromAddr address.Address, toAddr address.Address, amt types.BigInt) error {
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
From: fromAddr,
|
From: fromAddr,
|
||||||
To: toAddr,
|
To: toAddr,
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// RunClientTest exercises some of the Client CLI commands
|
// RunClientTest exercises some of the Client CLI commands
|
||||||
func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode TestFullNode) {
|
func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode *TestFullNode) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -145,13 +145,13 @@ func (n *Ensemble) FullNode(full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
|||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var key *wallet.Key
|
key, err := wallet.GenerateKey(types.KTBLS)
|
||||||
if !n.bootstrapped && !options.balance.IsZero() {
|
|
||||||
// create a key+address, and assign it some FIL; this will be set as the default wallet.
|
|
||||||
var err error
|
|
||||||
key, err = wallet.GenerateKey(types.KTBLS)
|
|
||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
|
|
||||||
|
if !n.bootstrapped && !options.balance.IsZero() {
|
||||||
|
// if we still haven't forged genesis, create a key+address, and assign
|
||||||
|
// it some FIL; this will be set as the default wallet when the node is
|
||||||
|
// started.
|
||||||
genacc := genesis.Actor{
|
genacc := genesis.Actor{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: options.balance,
|
Balance: options.balance,
|
||||||
@ -298,7 +298,6 @@ func (n *Ensemble) Start() *Ensemble {
|
|||||||
// Construct the full node.
|
// Construct the full node.
|
||||||
stop, err := node.New(ctx, opts...)
|
stop, err := node.New(ctx, opts...)
|
||||||
|
|
||||||
// fullOpts[i].Opts(fulls),
|
|
||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
|
|
||||||
addr, err := full.WalletImport(context.Background(), &full.DefaultKey.KeyInfo)
|
addr, err := full.WalletImport(context.Background(), &full.DefaultKey.KeyInfo)
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
// SendFunds sends funds from the default wallet of the specified sender node
|
// SendFunds sends funds from the default wallet of the specified sender node
|
||||||
// to the recipient address.
|
// to the recipient address.
|
||||||
func SendFunds(ctx context.Context, t *testing.T, sender TestFullNode, recipient address.Address, amount abi.TokenAmount) {
|
func SendFunds(ctx context.Context, t *testing.T, sender *TestFullNode, recipient address.Address, amount abi.TokenAmount) {
|
||||||
senderAddr, err := sender.WalletDefaultAddress(ctx)
|
senderAddr, err := sender.WalletDefaultAddress(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package itests
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -18,17 +17,16 @@ import (
|
|||||||
|
|
||||||
// TestMultisig does a basic test to exercise the multisig CLI commands
|
// TestMultisig does a basic test to exercise the multisig CLI commands
|
||||||
func TestMultisig(t *testing.T) {
|
func TestMultisig(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
|
||||||
kit2.QuietMiningLogs()
|
kit2.QuietMiningLogs()
|
||||||
|
|
||||||
blockTime := 5 * time.Millisecond
|
blockTime := 5 * time.Millisecond
|
||||||
client, _, ens := kit2.EnsembleMinimal(t, kit2.MockProofs(), kit2.ThroughRPC())
|
client, _, ens := kit2.EnsembleMinimal(t, kit2.MockProofs(), kit2.ThroughRPC())
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
runMultisigTests(t, *client)
|
runMultisigTests(t, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultisigTests(t *testing.T, clientNode kit2.TestFullNode) {
|
func runMultisigTests(t *testing.T, clientNode *kit2.TestFullNode) {
|
||||||
// Create mock CLI
|
// Create mock CLI
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
mockCLI := kit2.NewMockCLI(ctx, t, cli.Commands)
|
mockCLI := kit2.NewMockCLI(ctx, t, cli.Commands)
|
||||||
|
@ -51,7 +51,7 @@ func TestPaymentChannelsAPI(t *testing.T) {
|
|||||||
receiverAddr, err := paymentReceiver.WalletNew(ctx, types.KTSecp256k1)
|
receiverAddr, err := paymentReceiver.WalletNew(ctx, types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
kit2.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)
|
||||||
|
@ -428,7 +428,7 @@ func startPaychCreatorReceiverMiner(ctx context.Context, t *testing.T, paymentCr
|
|||||||
// Send some funds to the second node
|
// Send some funds to the second node
|
||||||
receiverAddr, err := paymentReceiver.WalletDefaultAddress(ctx)
|
receiverAddr, err := paymentReceiver.WalletDefaultAddress(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
kit2.SendFunds(ctx, t, *paymentCreator, receiverAddr, abi.NewTokenAmount(1e18))
|
kit2.SendFunds(ctx, t, paymentCreator, receiverAddr, abi.NewTokenAmount(1e18))
|
||||||
|
|
||||||
// Get the first node's address
|
// Get the first node's address
|
||||||
creatorAddr, err := paymentCreator.WalletDefaultAddress(ctx)
|
creatorAddr, err := paymentCreator.WalletDefaultAddress(ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user