update test-vectors commit.
This commit is contained in:
parent
b13681df32
commit
dddf7951ef
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
"github.com/filecoin-project/lotus/lib/blockstore"
|
"github.com/filecoin-project/lotus/lib/blockstore"
|
||||||
|
"github.com/filecoin-project/test-vectors/schema"
|
||||||
|
|
||||||
"github.com/ipld/go-car"
|
"github.com/ipld/go-car"
|
||||||
)
|
)
|
||||||
@ -110,7 +111,7 @@ func TestConformance(t *testing.T) {
|
|||||||
t.Fatalf("failed to read test raw file: %s", path)
|
t.Fatalf("failed to read test raw file: %s", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
var vector TestVector
|
var vector schema.TestVector
|
||||||
err = json.Unmarshal(raw, &vector)
|
err = json.Unmarshal(raw, &vector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to parse test vector %s: %s; skipping", path, err)
|
t.Errorf("failed to parse test vector %s: %s; skipping", path, err)
|
||||||
@ -130,7 +131,7 @@ func TestConformance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// executeMessageVector executes a message-class test vector.
|
// executeMessageVector executes a message-class test vector.
|
||||||
func executeMessageVector(t *testing.T, vector *TestVector) {
|
func executeMessageVector(t *testing.T, vector *schema.TestVector) {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
epoch = vector.Pre.Epoch
|
epoch = vector.Pre.Epoch
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
package conformance
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Class represents the type of test this instance is.
|
|
||||||
type Class string
|
|
||||||
|
|
||||||
var (
|
|
||||||
// ClassMessage tests the VM transition over a single message
|
|
||||||
ClassMessage Class = "message"
|
|
||||||
// ClassBlock tests the VM transition over a block of messages
|
|
||||||
ClassBlock Class = "block"
|
|
||||||
// ClassTipset tests the VM transition on a tipset update
|
|
||||||
ClassTipset Class = "tipset"
|
|
||||||
// ClassChain tests the VM transition across a chain segment
|
|
||||||
ClassChain Class = "chain"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Selector provides a filter to indicate what implementations this test is relevant for
|
|
||||||
type Selector string
|
|
||||||
|
|
||||||
// Metadata provides information on the generation of this test case
|
|
||||||
type Metadata struct {
|
|
||||||
ID string `json:"id"`
|
|
||||||
Version string `json:"version,omitempty"`
|
|
||||||
Desc string `json:"description,omitempty"`
|
|
||||||
Comment string `json:"comment,omitempty"`
|
|
||||||
Gen GenerationData `json:"gen"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GenerationData tags the source of this test case
|
|
||||||
type GenerationData struct {
|
|
||||||
Source string `json:"source,omitempty"`
|
|
||||||
Version string `json:"version,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// StateTree represents a state tree within preconditions and postconditions.
|
|
||||||
type StateTree struct {
|
|
||||||
RootCID cid.Cid `json:"root_cid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Base64EncodedBytes is a base64-encoded binary value.
|
|
||||||
type Base64EncodedBytes []byte
|
|
||||||
|
|
||||||
// Preconditions contain a representation of VM state at the beginning of the test
|
|
||||||
type Preconditions struct {
|
|
||||||
Epoch abi.ChainEpoch `json:"epoch"`
|
|
||||||
StateTree *StateTree `json:"state_tree"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receipt represents a receipt to match against.
|
|
||||||
type Receipt struct {
|
|
||||||
ExitCode exitcode.ExitCode `json:"exit_code"`
|
|
||||||
ReturnValue Base64EncodedBytes `json:"return"`
|
|
||||||
GasUsed int64 `json:"gas_used"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Postconditions contain a representation of VM state at th end of the test
|
|
||||||
type Postconditions struct {
|
|
||||||
StateTree *StateTree `json:"state_tree"`
|
|
||||||
Receipts []*Receipt `json:"receipts"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements json.Marshal for Base64EncodedBytes
|
|
||||||
func (beb Base64EncodedBytes) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(base64.StdEncoding.EncodeToString(beb))
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshal for Base64EncodedBytes
|
|
||||||
func (beb *Base64EncodedBytes) UnmarshalJSON(v []byte) error {
|
|
||||||
var s string
|
|
||||||
if err := json.Unmarshal(v, &s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes, err := base64.StdEncoding.DecodeString(s)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*beb = bytes
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestVector is a single test case
|
|
||||||
type TestVector struct {
|
|
||||||
Class `json:"class"`
|
|
||||||
Selector `json:"selector,omitempty"`
|
|
||||||
Meta *Metadata `json:"_meta"`
|
|
||||||
|
|
||||||
// CAR binary data to be loaded into the test environment, usually a CAR
|
|
||||||
// containing multiple state trees, addressed by root CID from the relevant
|
|
||||||
// objects.
|
|
||||||
CAR Base64EncodedBytes `json:"car"`
|
|
||||||
|
|
||||||
Pre *Preconditions `json:"preconditions"`
|
|
||||||
ApplyMessages []Message `json:"apply_messages"`
|
|
||||||
Post *Postconditions `json:"postconditions"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Message struct {
|
|
||||||
Bytes Base64EncodedBytes `json:"bytes"`
|
|
||||||
Epoch *abi.ChainEpoch `json:"epoch,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate validates this test vector against the JSON schema, and applies
|
|
||||||
// further validation rules that cannot be enforced through JSON Schema.
|
|
||||||
func (tv *TestVector) Validate() error {
|
|
||||||
// TODO validate against JSON Schema.
|
|
||||||
if tv.Class == ClassMessage {
|
|
||||||
if len(tv.Post.Receipts) != len(tv.ApplyMessages) {
|
|
||||||
return fmt.Errorf("length of postcondition receipts must match length of messages to apply")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
2
extern/test-vectors
vendored
2
extern/test-vectors
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9aec197823427e302533f85df4c28dd4cc42dc36
|
Subproject commit d0df1541d7eaa7d2cf98e2192b2fb857944a162a
|
2
go.mod
2
go.mod
@ -39,7 +39,7 @@ require (
|
|||||||
github.com/filecoin-project/specs-actors v0.9.3
|
github.com/filecoin-project/specs-actors v0.9.3
|
||||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200730063404-f7db367e9401
|
github.com/filecoin-project/specs-storage v0.1.1-0.20200730063404-f7db367e9401
|
||||||
github.com/filecoin-project/storage-fsm v0.0.0-20200805013058-9d9ea4e6331f
|
github.com/filecoin-project/storage-fsm v0.0.0-20200805013058-9d9ea4e6331f
|
||||||
github.com/filecoin-project/test-vectors v0.0.0-20200819133914-e20cc29cc926
|
github.com/filecoin-project/test-vectors v0.0.0-20200819163125-d0df1541d7ea
|
||||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||||
github.com/go-kit/kit v0.10.0
|
github.com/go-kit/kit v0.10.0
|
||||||
github.com/google/uuid v1.1.1
|
github.com/google/uuid v1.1.1
|
||||||
|
7
go.sum
7
go.sum
@ -223,6 +223,7 @@ github.com/filecoin-project/go-address v0.0.3 h1:eVfbdjEbpbzIrbiSa+PiGUY+oDK9HnU
|
|||||||
github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8=
|
github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8=
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg=
|
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg=
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg=
|
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg=
|
||||||
|
github.com/filecoin-project/go-amt-ipld/v2 v2.1.0 h1:t6qDiuGYYngDqaLc2ZUvdtAg4UNxPeOYaXhBWSNsVaM=
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs=
|
github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs=
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20200731171407-e559a0579161 h1:K6t4Hrs+rwUxBz2xg88Bdqeh4k5/rycQFdPseZhRyfE=
|
github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20200731171407-e559a0579161 h1:K6t4Hrs+rwUxBz2xg88Bdqeh4k5/rycQFdPseZhRyfE=
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20200731171407-e559a0579161/go.mod h1:vgmwKBkx+ca5OIeEvstiQgzAZnb7R6QaqE1oEDSqa6g=
|
github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20200731171407-e559a0579161/go.mod h1:vgmwKBkx+ca5OIeEvstiQgzAZnb7R6QaqE1oEDSqa6g=
|
||||||
@ -265,6 +266,8 @@ github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZO
|
|||||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg=
|
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg=
|
||||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8=
|
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8=
|
||||||
github.com/filecoin-project/lotus v0.4.3-0.20200815233716-a0c0d9c98aae/go.mod h1:fqqwJa43SJzGnFA6fzsbiubRoo7UxRkpA7JwNs7LZLo=
|
github.com/filecoin-project/lotus v0.4.3-0.20200815233716-a0c0d9c98aae/go.mod h1:fqqwJa43SJzGnFA6fzsbiubRoo7UxRkpA7JwNs7LZLo=
|
||||||
|
github.com/filecoin-project/lotus v0.4.3-0.20200819133134-a21234cd54d5/go.mod h1:YYUqCqyv4odVgKSFQAnIdAl0v1cIfbEYnF9E118dMGQ=
|
||||||
|
github.com/filecoin-project/lotus v0.4.3-0.20200819134055-b13681df3205/go.mod h1:rooripL/X8ixwUngDPzphAv/RKZXWBprbyxxDW0EJi0=
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo=
|
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo=
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200730050024-3ee28c3b6d9a/go.mod h1:oOawOl9Yk+qeytLzzIryjI8iRbqo+qzS6EEeElP4PWA=
|
github.com/filecoin-project/sector-storage v0.0.0-20200730050024-3ee28c3b6d9a/go.mod h1:oOawOl9Yk+qeytLzzIryjI8iRbqo+qzS6EEeElP4PWA=
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200810171746-eac70842d8e0 h1:E1fZ27fhKK05bhZItfTwqr1i05vXnEZJznQFEYwEEUU=
|
github.com/filecoin-project/sector-storage v0.0.0-20200810171746-eac70842d8e0 h1:E1fZ27fhKK05bhZItfTwqr1i05vXnEZJznQFEYwEEUU=
|
||||||
@ -337,6 +340,7 @@ github.com/gogo/status v1.1.0 h1:+eIkrewn5q6b30y+g/BJINVVdi2xH7je5MPJ3ZPK3JA=
|
|||||||
github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM=
|
github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
||||||
@ -1426,6 +1430,9 @@ github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee h1:lYbXeSv
|
|||||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee/go.mod h1:m2aV4LZI4Aez7dP5PMyVKEHhUyEJ/RjmPEDOpDvudHg=
|
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee/go.mod h1:m2aV4LZI4Aez7dP5PMyVKEHhUyEJ/RjmPEDOpDvudHg=
|
||||||
github.com/whyrusleeping/yamux v1.1.5/go.mod h1:E8LnQQ8HKx5KD29HZFUwM1PxCOdPRzGwur1mcYhXcD8=
|
github.com/whyrusleeping/yamux v1.1.5/go.mod h1:E8LnQQ8HKx5KD29HZFUwM1PxCOdPRzGwur1mcYhXcD8=
|
||||||
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
|
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
|
||||||
|
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||||
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||||
|
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
github.com/xlab/c-for-go v0.0.0-20200718154222-87b0065af829 h1:wb7xrDzfkLgPHsSEBm+VSx6aDdi64VtV0xvP0E6j8bk=
|
github.com/xlab/c-for-go v0.0.0-20200718154222-87b0065af829 h1:wb7xrDzfkLgPHsSEBm+VSx6aDdi64VtV0xvP0E6j8bk=
|
||||||
github.com/xlab/c-for-go v0.0.0-20200718154222-87b0065af829/go.mod h1:h/1PEBwj7Ym/8kOuMWvO2ujZ6Lt+TMbySEXNhjjR87I=
|
github.com/xlab/c-for-go v0.0.0-20200718154222-87b0065af829/go.mod h1:h/1PEBwj7Ym/8kOuMWvO2ujZ6Lt+TMbySEXNhjjR87I=
|
||||||
|
Loading…
Reference in New Issue
Block a user