fix test that references private symbols; avoid hacky test selection flags.
This commit is contained in:
parent
ec6c394de7
commit
539f8c1f61
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -55,9 +54,6 @@ import (
|
|||||||
// * asserts that miner B loses power
|
// * asserts that miner B loses power
|
||||||
// * asserts that miner D loses power, is inactive
|
// * asserts that miner D loses power, is inactive
|
||||||
func TestDeadlineToggling(t *testing.T) {
|
func TestDeadlineToggling(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_DEADLINE_TOGGLING") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_DEADLINE_TOGGLING=1 to run")
|
|
||||||
}
|
|
||||||
_ = logging.SetLogLevel("miner", "ERROR")
|
_ = logging.SetLogLevel("miner", "ERROR")
|
||||||
_ = logging.SetLogLevel("chainstore", "ERROR")
|
_ = logging.SetLogLevel("chainstore", "ERROR")
|
||||||
_ = logging.SetLogLevel("chain", "ERROR")
|
_ = logging.SetLogLevel("chain", "ERROR")
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
|
"github.com/filecoin-project/lotus/itests/multisig"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@ -188,7 +189,7 @@ func TestGatewayMsigCLI(t *testing.T) {
|
|||||||
defer nodes.closer()
|
defer nodes.closer()
|
||||||
|
|
||||||
lite := nodes.lite
|
lite := nodes.lite
|
||||||
runMultisigTests(t, lite)
|
multisig.RunMultisigTests(t, lite)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayDealFlow(t *testing.T) {
|
func TestGatewayDealFlow(t *testing.T) {
|
||||||
|
96
itests/multisig/suite.go
Normal file
96
itests/multisig/suite.go
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
package multisig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/cli"
|
||||||
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunMultisigTests(t *testing.T, clientNode kit.TestFullNode) {
|
||||||
|
// Create mock CLI
|
||||||
|
ctx := context.Background()
|
||||||
|
mockCLI := kit.NewMockCLI(ctx, t, cli.Commands)
|
||||||
|
clientCLI := mockCLI.Client(clientNode.ListenAddr)
|
||||||
|
|
||||||
|
// Create some wallets on the node to use for testing multisig
|
||||||
|
var walletAddrs []address.Address
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
addr, err := clientNode.WalletNew(ctx, types.KTSecp256k1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
walletAddrs = append(walletAddrs, addr)
|
||||||
|
|
||||||
|
kit.SendFunds(ctx, t, clientNode, addr, types.NewInt(1e15))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an msig with three of the addresses and threshold of two sigs
|
||||||
|
// msig create --required=2 --duration=50 --value=1000attofil <addr1> <addr2> <addr3>
|
||||||
|
amtAtto := types.NewInt(1000)
|
||||||
|
threshold := 2
|
||||||
|
paramDuration := "--duration=50"
|
||||||
|
paramRequired := fmt.Sprintf("--required=%d", threshold)
|
||||||
|
paramValue := fmt.Sprintf("--value=%dattofil", amtAtto)
|
||||||
|
out := clientCLI.RunCmd(
|
||||||
|
"msig", "create",
|
||||||
|
paramRequired,
|
||||||
|
paramDuration,
|
||||||
|
paramValue,
|
||||||
|
walletAddrs[0].String(),
|
||||||
|
walletAddrs[1].String(),
|
||||||
|
walletAddrs[2].String(),
|
||||||
|
)
|
||||||
|
fmt.Println(out)
|
||||||
|
|
||||||
|
// Extract msig robust address from output
|
||||||
|
expCreateOutPrefix := "Created new multisig:"
|
||||||
|
require.Regexp(t, regexp.MustCompile(expCreateOutPrefix), out)
|
||||||
|
parts := strings.Split(strings.TrimSpace(strings.Replace(out, expCreateOutPrefix, "", -1)), " ")
|
||||||
|
require.Len(t, parts, 2)
|
||||||
|
msigRobustAddr := parts[1]
|
||||||
|
fmt.Println("msig robust address:", msigRobustAddr)
|
||||||
|
|
||||||
|
// Propose to add a new address to the msig
|
||||||
|
// msig add-propose --from=<addr> <msig> <addr>
|
||||||
|
paramFrom := fmt.Sprintf("--from=%s", walletAddrs[0])
|
||||||
|
out = clientCLI.RunCmd(
|
||||||
|
"msig", "add-propose",
|
||||||
|
paramFrom,
|
||||||
|
msigRobustAddr,
|
||||||
|
walletAddrs[3].String(),
|
||||||
|
)
|
||||||
|
fmt.Println(out)
|
||||||
|
|
||||||
|
// msig inspect <msig>
|
||||||
|
out = clientCLI.RunCmd("msig", "inspect", "--vesting", "--decode-params", msigRobustAddr)
|
||||||
|
fmt.Println(out)
|
||||||
|
|
||||||
|
// Expect correct balance
|
||||||
|
require.Regexp(t, regexp.MustCompile("Balance: 0.000000000000001 FIL"), out)
|
||||||
|
// Expect 1 transaction
|
||||||
|
require.Regexp(t, regexp.MustCompile(`Transactions:\s*1`), out)
|
||||||
|
// Expect transaction to be "AddSigner"
|
||||||
|
require.Regexp(t, regexp.MustCompile(`AddSigner`), out)
|
||||||
|
|
||||||
|
// Approve adding the new address
|
||||||
|
// msig add-approve --from=<addr> <msig> <addr> 0 <addr> false
|
||||||
|
txnID := "0"
|
||||||
|
paramFrom = fmt.Sprintf("--from=%s", walletAddrs[1])
|
||||||
|
out = clientCLI.RunCmd(
|
||||||
|
"msig", "add-approve",
|
||||||
|
paramFrom,
|
||||||
|
msigRobustAddr,
|
||||||
|
walletAddrs[0].String(),
|
||||||
|
txnID,
|
||||||
|
walletAddrs[3].String(),
|
||||||
|
"false",
|
||||||
|
)
|
||||||
|
fmt.Println(out)
|
||||||
|
}
|
@ -2,18 +2,12 @@ package itests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
"github.com/filecoin-project/lotus/cli"
|
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/filecoin-project/lotus/itests/multisig"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestMultisig does a basic test to exercise the multisig CLI commands
|
// TestMultisig does a basic test to exercise the multisig CLI commands
|
||||||
@ -25,86 +19,5 @@ func TestMultisig(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
clientNode, _ := kit.StartOneNodeOneMiner(ctx, t, blocktime)
|
clientNode, _ := kit.StartOneNodeOneMiner(ctx, t, blocktime)
|
||||||
|
|
||||||
runMultisigTests(t, clientNode)
|
multisig.RunMultisigTests(t, clientNode)
|
||||||
}
|
|
||||||
|
|
||||||
func runMultisigTests(t *testing.T, clientNode kit.TestFullNode) {
|
|
||||||
// Create mock CLI
|
|
||||||
ctx := context.Background()
|
|
||||||
mockCLI := kit.NewMockCLI(ctx, t, cli.Commands)
|
|
||||||
clientCLI := mockCLI.Client(clientNode.ListenAddr)
|
|
||||||
|
|
||||||
// Create some wallets on the node to use for testing multisig
|
|
||||||
var walletAddrs []address.Address
|
|
||||||
for i := 0; i < 4; i++ {
|
|
||||||
addr, err := clientNode.WalletNew(ctx, types.KTSecp256k1)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
walletAddrs = append(walletAddrs, addr)
|
|
||||||
|
|
||||||
kit.SendFunds(ctx, t, clientNode, addr, types.NewInt(1e15))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an msig with three of the addresses and threshold of two sigs
|
|
||||||
// msig create --required=2 --duration=50 --value=1000attofil <addr1> <addr2> <addr3>
|
|
||||||
amtAtto := types.NewInt(1000)
|
|
||||||
threshold := 2
|
|
||||||
paramDuration := "--duration=50"
|
|
||||||
paramRequired := fmt.Sprintf("--required=%d", threshold)
|
|
||||||
paramValue := fmt.Sprintf("--value=%dattofil", amtAtto)
|
|
||||||
out := clientCLI.RunCmd(
|
|
||||||
"msig", "create",
|
|
||||||
paramRequired,
|
|
||||||
paramDuration,
|
|
||||||
paramValue,
|
|
||||||
walletAddrs[0].String(),
|
|
||||||
walletAddrs[1].String(),
|
|
||||||
walletAddrs[2].String(),
|
|
||||||
)
|
|
||||||
fmt.Println(out)
|
|
||||||
|
|
||||||
// Extract msig robust address from output
|
|
||||||
expCreateOutPrefix := "Created new multisig:"
|
|
||||||
require.Regexp(t, regexp.MustCompile(expCreateOutPrefix), out)
|
|
||||||
parts := strings.Split(strings.TrimSpace(strings.Replace(out, expCreateOutPrefix, "", -1)), " ")
|
|
||||||
require.Len(t, parts, 2)
|
|
||||||
msigRobustAddr := parts[1]
|
|
||||||
fmt.Println("msig robust address:", msigRobustAddr)
|
|
||||||
|
|
||||||
// Propose to add a new address to the msig
|
|
||||||
// msig add-propose --from=<addr> <msig> <addr>
|
|
||||||
paramFrom := fmt.Sprintf("--from=%s", walletAddrs[0])
|
|
||||||
out = clientCLI.RunCmd(
|
|
||||||
"msig", "add-propose",
|
|
||||||
paramFrom,
|
|
||||||
msigRobustAddr,
|
|
||||||
walletAddrs[3].String(),
|
|
||||||
)
|
|
||||||
fmt.Println(out)
|
|
||||||
|
|
||||||
// msig inspect <msig>
|
|
||||||
out = clientCLI.RunCmd("msig", "inspect", "--vesting", "--decode-params", msigRobustAddr)
|
|
||||||
fmt.Println(out)
|
|
||||||
|
|
||||||
// Expect correct balance
|
|
||||||
require.Regexp(t, regexp.MustCompile("Balance: 0.000000000000001 FIL"), out)
|
|
||||||
// Expect 1 transaction
|
|
||||||
require.Regexp(t, regexp.MustCompile(`Transactions:\s*1`), out)
|
|
||||||
// Expect transaction to be "AddSigner"
|
|
||||||
require.Regexp(t, regexp.MustCompile(`AddSigner`), out)
|
|
||||||
|
|
||||||
// Approve adding the new address
|
|
||||||
// msig add-approve --from=<addr> <msig> <addr> 0 <addr> false
|
|
||||||
txnID := "0"
|
|
||||||
paramFrom = fmt.Sprintf("--from=%s", walletAddrs[1])
|
|
||||||
out = clientCLI.RunCmd(
|
|
||||||
"msig", "add-approve",
|
|
||||||
paramFrom,
|
|
||||||
msigRobustAddr,
|
|
||||||
walletAddrs[0].String(),
|
|
||||||
txnID,
|
|
||||||
walletAddrs[3].String(),
|
|
||||||
"false",
|
|
||||||
)
|
|
||||||
fmt.Println(out)
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTerminate(t *testing.T) {
|
func TestTerminate(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
const blocktime = 2 * time.Millisecond
|
const blocktime = 2 * time.Millisecond
|
||||||
|
@ -23,10 +23,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestWindowPostDispute(t *testing.T) {
|
func TestWindowPostDispute(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
b := kit.MockMinerBuilder
|
b := kit.MockMinerBuilder
|
||||||
@ -254,10 +250,6 @@ func TestWindowPostDispute(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWindowPostDisputeFails(t *testing.T) {
|
func TestWindowPostDisputeFails(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
b := kit.MockMinerBuilder
|
b := kit.MockMinerBuilder
|
||||||
|
@ -3,7 +3,6 @@ package itests
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -23,10 +22,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestWindowedPost(t *testing.T) {
|
func TestWindowedPost(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -264,10 +259,6 @@ func testWindowPostUpgrade(t *testing.T, b kit.APIBuilder, blocktime time.Durati
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWindowPostBaseFeeNoBurn(t *testing.T) {
|
func TestWindowPostBaseFeeNoBurn(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -323,10 +314,6 @@ waitForProof:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWindowPostBaseFeeBurn(t *testing.T) {
|
func TestWindowPostBaseFeeBurn(t *testing.T) {
|
||||||
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
|
|
||||||
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
Loading…
Reference in New Issue
Block a user