Skip to content

Commit

Permalink
chore: fix lint & test
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Feb 10, 2023
1 parent 2ab2ec3 commit b19e6df
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ Response:
{
"Flags": 7,
"Key": "string value",
"Codec": 42,
"Value": "Ynl0ZSBhcnJheQ=="
}
]
Expand Down
1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
+ BlockTime
- ChainBlockstoreInfo
- ChainCheckBlockstore
> ChainGetEvents {[func(context.Context, cid.Cid) ([]types.Event, error) <> func(context.Context, cid.Cid) ([]types.Event, error)] base=func out type: #0 input; nested={[[]types.Event <> []types.Event] base=slice element; nested={[types.Event <> types.Event] base=struct field; nested={[types.Event <> types.Event] base=exported field type: #1 field named Entries; nested={[[]types.EventEntry <> []types.EventEntry] base=slice element; nested={[types.EventEntry <> types.EventEntry] base=struct field; nested={[types.EventEntry <> types.EventEntry] base=exported fields count: 4 != 3; nested=nil}}}}}}}
- ChainGetNode
+ ChainGetReceipts
+ ChainList
Expand Down
66 changes: 66 additions & 0 deletions venus-shared/types/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func TestMessageValidForBlockInclusion(t *testing.T) {
ip := testutil.IntRangedProvider(0, int(params.FilBase))
return FromFil(uint64(ip(t)))
},
func(t *testing.T) address.Address {
for {
if addr := testutil.AddressProvider()(t); addr.Protocol() != address.Delegated {
return addr
}
}
},
)

// ensure that random assignments won't break the validation
Expand Down Expand Up @@ -207,4 +214,63 @@ func TestMessageValidForBlockInclusion(t *testing.T) {

testutil.ValueSetNReset(t, c.name, onSet, onReset, c.sets...)
}

delegateAddr := testutil.DelegatedAddressProvider(32)(t)
addrCases := []struct {
name string
sets []interface{}
from address.Address
to address.Address
version network.Version
expectErr bool
}{
{
name: "from is delegate address, version < Version18",
sets: []interface{}{
&msg.From,
delegateAddr,
},
version: 17,
expectErr: true,
},
{
name: "from is delegate address, version >= Version18",
sets: []interface{}{
&msg.From,
delegateAddr,
},
version: 18,
},
{
name: "to is delegate address, version < Version18",
sets: []interface{}{
&msg.To,
delegateAddr,
},
version: 17,
expectErr: true,
},
{
name: "to is delegate address, version >= Version18",
sets: []interface{}{
&msg.To,
delegateAddr,
},
version: 18,
},
}
for _, c := range addrCases {
onSet := func() {
if err := msg.ValidForBlockInclusion(0, c.version); err != nil && !c.expectErr {
require.Errorf(t, err, "after invalid values set for %s", c.name)
}
}

onReset := func() {
err := msg.ValidForBlockInclusion(0, c.version)
require.NoErrorf(t, err, "after values reset for %s", c.name)
}

testutil.ValueSetNReset(t, c.name, onSet, onReset, c.sets...)
}
}

0 comments on commit b19e6df

Please sign in to comment.