fix client tests.
This commit is contained in:
parent
20dfe220f3
commit
b56568d720
@ -37,23 +37,23 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode TestFullNode)
|
|||||||
minerAddr := addrs[0]
|
minerAddr := addrs[0]
|
||||||
fmt.Println("Miner:", minerAddr)
|
fmt.Println("Miner:", minerAddr)
|
||||||
|
|
||||||
// Client query-ask <Miner addr>
|
// client query-ask <Miner addr>
|
||||||
out := clientCLI.RunCmd("client", "query-ask", minerAddr.String())
|
out := clientCLI.RunCmd("client", "query-ask", minerAddr.String())
|
||||||
require.Regexp(t, regexp.MustCompile("Ask:"), out)
|
require.Regexp(t, regexp.MustCompile("Ask:"), out)
|
||||||
|
|
||||||
// Create a deal (non-interactive)
|
// Create a deal (non-interactive)
|
||||||
// Client deal --start-epoch=<start epoch> <cid> <Miner addr> 1000000attofil <duration>
|
// client deal --start-epoch=<start epoch> <cid> <Miner addr> 1000000attofil <duration>
|
||||||
res, _, err := CreateImportFile(ctx, clientNode, 1)
|
res, _, err := CreateImportFile(ctx, clientNode, 1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
startEpoch := fmt.Sprintf("--start-epoch=%d", 2<<12)
|
startEpoch := fmt.Sprintf("--start-epoch=%d", 2<<12)
|
||||||
dataCid := res.Root
|
dataCid := res.Root
|
||||||
price := "1000000attofil"
|
price := "1000000attofil"
|
||||||
duration := fmt.Sprintf("%d", build.MinDealDuration)
|
duration := fmt.Sprintf("%d", build.MinDealDuration)
|
||||||
out = clientCLI.RunCmd("Client", "deal", startEpoch, dataCid.String(), minerAddr.String(), price, duration)
|
out = clientCLI.RunCmd("client", "deal", startEpoch, dataCid.String(), minerAddr.String(), price, duration)
|
||||||
fmt.Println("Client deal", out)
|
fmt.Println("client deal", out)
|
||||||
|
|
||||||
// Create a deal (interactive)
|
// Create a deal (interactive)
|
||||||
// Client deal
|
// client deal
|
||||||
// <cid>
|
// <cid>
|
||||||
// <duration> (in days)
|
// <duration> (in days)
|
||||||
// <Miner addr>
|
// <Miner addr>
|
||||||
@ -63,7 +63,7 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode TestFullNode)
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
dataCid2 := res.Root
|
dataCid2 := res.Root
|
||||||
duration = fmt.Sprintf("%d", build.MinDealDuration/builtin.EpochsInDay)
|
duration = fmt.Sprintf("%d", build.MinDealDuration/builtin.EpochsInDay)
|
||||||
cmd := []string{"Client", "deal"}
|
cmd := []string{"client", "deal"}
|
||||||
interactiveCmds := []string{
|
interactiveCmds := []string{
|
||||||
dataCid2.String(),
|
dataCid2.String(),
|
||||||
duration,
|
duration,
|
||||||
@ -72,13 +72,13 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode TestFullNode)
|
|||||||
"yes",
|
"yes",
|
||||||
}
|
}
|
||||||
out = clientCLI.RunInteractiveCmd(cmd, interactiveCmds)
|
out = clientCLI.RunInteractiveCmd(cmd, interactiveCmds)
|
||||||
fmt.Println("Client deal:\n", out)
|
fmt.Println("client deal:\n", out)
|
||||||
|
|
||||||
// Wait for provider to start sealing deal
|
// Wait for provider to start sealing deal
|
||||||
dealStatus := ""
|
dealStatus := ""
|
||||||
for {
|
for {
|
||||||
// Client list-deals
|
// client list-deals
|
||||||
out = clientCLI.RunCmd("Client", "list-deals")
|
out = clientCLI.RunCmd("client", "list-deals")
|
||||||
fmt.Println("list-deals:\n", out)
|
fmt.Println("list-deals:\n", out)
|
||||||
|
|
||||||
lines := strings.Split(out, "\n")
|
lines := strings.Split(out, "\n")
|
||||||
@ -101,11 +101,11 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode TestFullNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the first file from the Miner
|
// Retrieve the first file from the Miner
|
||||||
// Client retrieve <cid> <file path>
|
// client retrieve <cid> <file path>
|
||||||
tmpdir, err := ioutil.TempDir(os.TempDir(), "test-cli-Client")
|
tmpdir, err := ioutil.TempDir(os.TempDir(), "test-cli-Client")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
path := filepath.Join(tmpdir, "outfile.dat")
|
path := filepath.Join(tmpdir, "outfile.dat")
|
||||||
out = clientCLI.RunCmd("Client", "retrieve", dataCid.String(), path)
|
out = clientCLI.RunCmd("client", "retrieve", dataCid.String(), path)
|
||||||
fmt.Println("retrieve:\n", out)
|
fmt.Println("retrieve:\n", out)
|
||||||
require.Regexp(t, regexp.MustCompile("Success"), out)
|
require.Regexp(t, regexp.MustCompile("Success"), out)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user