nested and paych suites in generator format (#235)
This commit is contained in:
parent
b2c2a7b5d0
commit
0afeed6108
@ -53,8 +53,17 @@ jobs:
|
||||
name: "build tvx"
|
||||
command: pushd tvx && go build .
|
||||
- run:
|
||||
name: "run messages test vector suite"
|
||||
name: "run messages test vector suite (deprecated api)"
|
||||
command: pushd tvx && ./tvx suite-messages | ./tvx exec-lotus
|
||||
- run:
|
||||
name: "run messages test vector suite (new api) - msg_application"
|
||||
command: pushd tvx/scripts/msg_application && go build . && ./msg_application | ../../tvx exec-lotus
|
||||
- run:
|
||||
name: "run messages test vector suite (new api) - nested send"
|
||||
command: pushd tvx/scripts/nested && go build . && ./nested | ../../tvx exec-lotus
|
||||
- run:
|
||||
name: "run messages test vector suite (new api) - paych"
|
||||
command: pushd tvx/scripts/paych && go build . && ./paych | ../../tvx exec-lotus
|
||||
soup-build-linux:
|
||||
executor: linux
|
||||
steps:
|
||||
|
127
tvx/scripts/nested/main.go
Normal file
127
tvx/scripts/nested/main.go
Normal file
@ -0,0 +1,127 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
. "github.com/filecoin-project/oni/tvx/builders"
|
||||
"github.com/filecoin-project/oni/tvx/schema"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g := NewGenerator()
|
||||
|
||||
g.MessageVectorGroup("nested_sends",
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "ok-basic",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_OkBasic,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "ok-to-new-actor",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_OkToNewActor,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "ok-to-new-actor-with-invoke",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_OkToNewActorWithInvoke,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "ok-recursive",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_OkRecursive,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "ok-non-cbor-params-with-transfer",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_OKNonCBORParamsWithTransfer,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-non-existent-id-address",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailNonexistentIDAddress,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-non-existent-actor-address",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailNonexistentActorAddress,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-invalid-method-num-new-actor",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailInvalidMethodNumNewActor,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-invalid-method-num-for-actor",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailInvalidMethodNumForActor,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-missing-params",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailMissingParams,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-mismatch-params",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailMismatchParams,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-inner-abort",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailInnerAbort,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-aborted-exec",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailAbortedExec,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "fail-insufficient-funds-for-transfer-in-inner-send",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: nestedSends_FailInsufficientFundsForTransferInInnerSend,
|
||||
},
|
||||
)
|
||||
|
||||
g.Wait()
|
||||
}
|
@ -2,8 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
//"fmt"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
@ -13,17 +11,14 @@ import (
|
||||
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
typegen "github.com/whyrusleeping/cbor-gen"
|
||||
//"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||
"github.com/filecoin-project/specs-actors/actors/puppet"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
typegen "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
. "github.com/filecoin-project/oni/tvx/builders"
|
||||
"github.com/filecoin-project/oni/tvx/schema"
|
||||
//"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -42,63 +37,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
nestedSends_OkBasic()
|
||||
nestedSends_OkToNewActor()
|
||||
nestedSends_OkToNewActorWithInvoke()
|
||||
nestedSends_OkRecursive()
|
||||
nestedSends_OKNonCBORParamsWithTransfer()
|
||||
|
||||
// TODO: Tests to exercise invalid "syntax" of the inner message.
|
||||
// These would fail message syntax validation if the message were top-level.
|
||||
//
|
||||
// Some of these require handcrafting the proposal params serialization.
|
||||
// - malformed address: zero-length, one-length, too-short pubkeys, invalid UVarints, ...
|
||||
// - negative method num
|
||||
//
|
||||
// Unfortunately the multisig actor can't be used to trigger a negative-value internal transfer because
|
||||
// it checks just before sending.
|
||||
// We need a custom actor for staging whackier messages.
|
||||
|
||||
//
|
||||
// The following tests exercise invalid semantics of the inner message
|
||||
//
|
||||
|
||||
nestedSends_FailNonexistentIDAddress()
|
||||
nestedSends_FailNonexistentActorAddress()
|
||||
nestedSends_FailInvalidMethodNumNewActor()
|
||||
nestedSends_FailInvalidMethodNumForActor()
|
||||
|
||||
// The multisig actor checks before attempting to transfer more than its balance, so we can't exercise that
|
||||
// the VM also checks this. Need a custome actor to exercise this.
|
||||
//t.Run("fail insufficient funds", func(t *testing.T) {
|
||||
// td := builder.Build(t)
|
||||
// defer td.Complete()
|
||||
//
|
||||
// stage := prepareStage(td, acctDefaultBalance, multisigBalance)
|
||||
// balanceBefore := td.GetBalance(stage.creator)
|
||||
//
|
||||
// // Attempt to transfer from the multisig more than the balance it has.
|
||||
// // The proposal to do should succeed, but the inner message fail.
|
||||
// amtSent := big.Add(multisigBalance, abi.NewTokenAmount(1))
|
||||
// result := stage.send(stage.creator, amtSent, builtin.MethodSend, nil, nonce)
|
||||
// assert.Equal(t, exitcode_spec.Ok, result.Receipt.ExitCode)
|
||||
//
|
||||
// td.AssertBalance(stage.msAddr, multisigBalance) // No change.
|
||||
// td.AssertBalance(stage.creator, big.Sub(balanceBefore, result.Receipt.GasUsed.Big())) // Pay gas, don't receive funds.
|
||||
//})
|
||||
|
||||
nestedSends_FailMissingParams()
|
||||
nestedSends_FailMismatchParams()
|
||||
nestedSends_FailInnerAbort()
|
||||
nestedSends_FailAbortedExec()
|
||||
nestedSends_FailInsufficientFundsForTransferInInnerSend()
|
||||
}
|
||||
|
||||
func nestedSends_OkBasic() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-ok-basic", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_OkBasic(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -111,14 +50,9 @@ func nestedSends_OkBasic() {
|
||||
//td.AssertActor(stage.creator, big.Sub(big.Add(balanceBefore, amtSent), result.Receipt.GasUsed.Big()), nonce+1)
|
||||
v.Assert.NonceEq(stage.creator, nonce+1)
|
||||
v.Assert.BalanceEq(stage.creator, big.Sub(big.Add(balanceBefore, amtSent), big.NewInt(result.MessageReceipt.GasUsed)))
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_OkToNewActor() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-ok-to-new-actor", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_OkToNewActor(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -132,14 +66,9 @@ func nestedSends_OkToNewActor() {
|
||||
v.Assert.BalanceEq(stage.msAddr, big.Sub(multisigBalance, amtSent))
|
||||
v.Assert.BalanceEq(stage.creator, big.Sub(balanceBefore, big.NewInt(result.MessageReceipt.GasUsed)))
|
||||
v.Assert.BalanceEq(newAddr, amtSent)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_OkToNewActorWithInvoke() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-ok-to-new-actor-with-invoke", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_OkToNewActorWithInvoke(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -159,14 +88,9 @@ func nestedSends_OkToNewActorWithInvoke() {
|
||||
v.Assert.BalanceEq(stage.msAddr, big.Sub(multisigBalance, amtSent))
|
||||
v.Assert.BalanceEq(stage.creator, big.Sub(balanceBefore, big.NewInt(result.MessageReceipt.GasUsed)))
|
||||
v.Assert.BalanceEq(newAddr, amtSent)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_OkRecursive() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-ok-recursive", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_OkRecursive(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
another := v.Actors.Account(address.SECP256K1, big.Zero())
|
||||
@ -186,14 +110,9 @@ func nestedSends_OkRecursive() {
|
||||
var st multisig.State
|
||||
v.Actors.ActorState(stage.msAddr, &st)
|
||||
v.Assert.Equal([]address.Address{stage.creator, another.ID}, st.Signers)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_OKNonCBORParamsWithTransfer() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-ok-non-cbor-params-with-transfer", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_OKNonCBORParamsWithTransfer(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -206,14 +125,9 @@ func nestedSends_OKNonCBORParamsWithTransfer() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, big.Sub(multisigBalance, amtSent))
|
||||
v.Assert.BalanceEq(newAddr, amtSent)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailNonexistentIDAddress() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-nonexistent-id-address", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailNonexistentIDAddress(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -224,14 +138,9 @@ func nestedSends_FailNonexistentIDAddress() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.ActorMissing(newAddr)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailNonexistentActorAddress() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-nonexistent-actor-address", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailNonexistentActorAddress(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -242,14 +151,9 @@ func nestedSends_FailNonexistentActorAddress() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.ActorMissing(newAddr)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailInvalidMethodNumNewActor() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-invalid-methodnum-new-actor", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailInvalidMethodNumNewActor(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -260,14 +164,9 @@ func nestedSends_FailInvalidMethodNumNewActor() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.ActorMissing(newAddr)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailInvalidMethodNumForActor() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-invalid-methodnum-for-actor", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailInvalidMethodNumForActor(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -278,14 +177,9 @@ func nestedSends_FailInvalidMethodNumForActor() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.BalanceEq(stage.creator, big.Sub(balanceBefore, big.NewInt(result.MessageReceipt.GasUsed))) // Pay gas, don't receive funds.
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailMissingParams() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-missing-params", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailMissingParams(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -298,14 +192,9 @@ func nestedSends_FailMissingParams() {
|
||||
v.Assert.BalanceEq(stage.creator, big.Sub(balanceBefore, big.NewInt(result.MessageReceipt.GasUsed)))
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.Equal(1, len(stage.state().Signers)) // No new signers
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailMismatchParams() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-mismatched-params", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailMismatchParams(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -324,14 +213,9 @@ func nestedSends_FailMismatchParams() {
|
||||
v.Assert.BalanceEq(stage.creator, big.Sub(balanceBefore, big.NewInt(result.MessageReceipt.GasUsed)))
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.Equal(1, len(stage.state().Signers)) // No new signers
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailInnerAbort() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-inner-abort", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailInnerAbort(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -348,14 +232,9 @@ func nestedSends_FailInnerAbort() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.HeadEq(builtin.RewardActorAddr, prevHead)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailAbortedExec() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-aborted-exec", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailAbortedExec(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
stage := prepareStage(v, acctDefaultBalance, multisigBalance)
|
||||
@ -376,14 +255,9 @@ func nestedSends_FailAbortedExec() {
|
||||
|
||||
v.Assert.BalanceEq(stage.msAddr, multisigBalance) // No change.
|
||||
v.Assert.HeadEq(builtin.InitActorAddr, prevHead) // Init state unchanged.
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func nestedSends_FailInsufficientFundsForTransferInInnerSend() {
|
||||
metadata := &schema.Metadata{ID: "nested-sends-fail-insufficient-funds-for-transfer-in-inner-send", Version: "v1", Desc: ""}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func nestedSends_FailInsufficientFundsForTransferInInnerSend(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
// puppet actor has zero funds
|
||||
@ -421,8 +295,6 @@ func nestedSends_FailInsufficientFundsForTransferInInnerSend() {
|
||||
// alice should be charged for the gas cost and bob should have not received any funds.
|
||||
v.Assert.BalanceEq(alice.ID, big.Sub(acctDefaultBalance, big.NewInt(msg.Result.GasUsed)))
|
||||
v.Assert.BalanceEq(bob.ID, big.Zero())
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
type msStage struct {
|
@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "github.com/filecoin-project/specs-actors/actors/abi"
|
||||
import (
|
||||
. "github.com/filecoin-project/oni/tvx/builders"
|
||||
"github.com/filecoin-project/oni/tvx/schema"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
)
|
||||
|
||||
var (
|
||||
initialBal = abi.NewTokenAmount(200_000_000_000)
|
||||
@ -8,7 +12,34 @@ var (
|
||||
)
|
||||
|
||||
func main() {
|
||||
happyPathCreate()
|
||||
happyPathUpdate()
|
||||
happyPathCollect()
|
||||
g := NewGenerator()
|
||||
|
||||
g.MessageVectorGroup("paych",
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "create-ok",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: happyPathCreate,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "update-ok",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: happyPathUpdate,
|
||||
},
|
||||
&MessageVectorGenItem{
|
||||
Metadata: &schema.Metadata{
|
||||
ID: "collect-ok",
|
||||
Version: "v1",
|
||||
Desc: "",
|
||||
},
|
||||
Func: happyPathCollect,
|
||||
},
|
||||
)
|
||||
|
||||
g.Wait()
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
@ -12,13 +10,9 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||
|
||||
. "github.com/filecoin-project/oni/tvx/builders"
|
||||
"github.com/filecoin-project/oni/tvx/schema"
|
||||
)
|
||||
|
||||
func happyPathCreate() {
|
||||
metadata := &schema.Metadata{ID: "paych-create-ok", Version: "v1", Desc: "payment channel create"}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func happyPathCreate(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
// Set up sender and receiver accounts.
|
||||
@ -47,12 +41,10 @@ func happyPathCreate() {
|
||||
v.Assert.Equal(sender.ID, state.From)
|
||||
v.Assert.Equal(receiver.ID, state.To)
|
||||
v.Assert.Equal(toSend, actor.Balance)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func happyPathUpdate() {
|
||||
metadata := &schema.Metadata{ID: "paych-update-ok", Version: "v1", Desc: "payment channel update"}
|
||||
func happyPathUpdate(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
var (
|
||||
timelock = abi.ChainEpoch(0)
|
||||
@ -65,9 +57,6 @@ func happyPathUpdate() {
|
||||
var sender, receiver AddressHandle
|
||||
var paychAddr AddressHandle
|
||||
|
||||
v := MessageVector(metadata)
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
v.Actors.AccountN(address.SECP256K1, initialBal, &sender, &receiver)
|
||||
paychAddr = AddressHandle{
|
||||
ID: MustNewIDAddr(MustIDFromAddress(receiver.ID) + 1),
|
||||
@ -112,14 +101,9 @@ func happyPathUpdate() {
|
||||
v.Assert.Equal(amount, ls.Redeemed)
|
||||
v.Assert.Equal(nonce, ls.Nonce)
|
||||
v.Assert.Equal(lane, ls.ID)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
||||
func happyPathCollect() {
|
||||
metadata := &schema.Metadata{ID: "paych-collect-ok", Version: "v1", Desc: "payment channel collect"}
|
||||
|
||||
v := MessageVector(metadata)
|
||||
func happyPathCollect(v *Builder) {
|
||||
v.Messages.SetDefaults(GasLimit(1_000_000_000), GasPrice(1))
|
||||
|
||||
// Set up sender and receiver accounts.
|
||||
@ -169,6 +153,4 @@ func happyPathCollect() {
|
||||
// the paych actor should have been deleted after the collect
|
||||
v.Assert.ActorMissing(paychAddr.Robust)
|
||||
v.Assert.ActorMissing(paychAddr.ID)
|
||||
|
||||
v.Finish(os.Stdout)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user