diff --git a/chain/actors/actors_test.go b/chain/actors/actors_test.go index ba153b6f5..2bc179345 100644 --- a/chain/actors/actors_test.go +++ b/chain/actors/actors_test.go @@ -65,7 +65,7 @@ func TestVMInvokeMethod(t *testing.T) { from := addrs[0] var err error - cenc, err := SerializeParams(&StorageMinerConstructorParams{}) + cenc, err := SerializeParams(&StorageMinerConstructorParams{Owner: from, Worker: from}) if err != nil { t.Fatal(err) } @@ -116,6 +116,7 @@ func TestStorageMarketActorCreateMiner(t *testing.T) { cheatStorageMarketTotal(t, vm, bs) params := &StorageMinerConstructorParams{ + Owner: maddr, Worker: maddr, SectorSize: types.NewInt(build.SectorSize), PeerID: "fakepeerid", diff --git a/chain/address/address.go b/chain/address/address.go index fd5c28dff..f06807757 100644 --- a/chain/address/address.go +++ b/chain/address/address.go @@ -325,6 +325,10 @@ func hash(ingest []byte, cfg *blake2b.Config) []byte { } func (a Address) MarshalCBOR(w io.Writer) error { + if a == Undef { + return fmt.Errorf("cannot marshal undefined address") + } + abytes := a.Bytes() if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(abytes)))); err != nil { return err @@ -360,6 +364,9 @@ func (a *Address) UnmarshalCBOR(br io.Reader) error { if err != nil { return err } + if addr == Undef { + return fmt.Errorf("cbor input should not contain empty addresses") + } *a = addr diff --git a/chain/events/events_test.go b/chain/events/events_test.go index a74417f0e..733c728b6 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -45,9 +45,11 @@ func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet } func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet { + a, _ := address.NewFromString("t00") ts, err := types.NewTipSet([]*types.BlockHeader{ { Height: h, + Miner: a, ParentStateRoot: dummyCid, Messages: msgcid, @@ -479,7 +481,7 @@ func TestCalled(t *testing.T) { fcs.advance(0, 3, map[int]cid.Cid{ // msg at H=6; H=8 (confidence=2) 0: fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 1}, + {To: t0123, From: t0123, Method: 5, Nonce: 1}, }, }), }) @@ -520,7 +522,7 @@ func TestCalled(t *testing.T) { n2msg := fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 2}, + {To: t0123, From: t0123, Method: 5, Nonce: 2}, }, }) @@ -574,7 +576,7 @@ func TestCalled(t *testing.T) { fcs.advance(0, 1, map[int]cid.Cid{ // msg at H=16; H=16 0: fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 3}, + {To: t0123, From: t0123, Method: 5, Nonce: 3}, }, }), }) @@ -597,7 +599,7 @@ func TestCalled(t *testing.T) { fcs.advance(0, 4, map[int]cid.Cid{ // msg at H=26; H=29 0: fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 4}, // this signals we don't want more + {To: t0123, From: t0123, Method: 5, Nonce: 4}, // this signals we don't want more }, }), }) @@ -609,7 +611,7 @@ func TestCalled(t *testing.T) { fcs.advance(0, 4, map[int]cid.Cid{ // msg at H=26; H=29 0: fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 5}, + {To: t0123, From: t0123, Method: 5, Nonce: 5}, }, }), }) @@ -754,12 +756,12 @@ func TestCalledOrder(t *testing.T) { fcs.advance(0, 10, map[int]cid.Cid{ 1: fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 1}, + {To: t0123, From: t0123, Method: 5, Nonce: 1}, }, }), 2: fcs.fakeMsgs(fakeMsg{ bmsgs: []*types.Message{ - {To: t0123, Method: 5, Nonce: 2}, + {To: t0123, From: t0123, Method: 5, Nonce: 2}, }, }), }) diff --git a/chain/events/tscache_test.go b/chain/events/tscache_test.go index 57c8aa463..33953dc7b 100644 --- a/chain/events/tscache_test.go +++ b/chain/events/tscache_test.go @@ -2,9 +2,11 @@ package events import ( "context" - "github.com/stretchr/testify/require" "testing" + "github.com/stretchr/testify/require" + + "github.com/filecoin-project/go-lotus/chain/address" "github.com/filecoin-project/go-lotus/chain/types" ) @@ -16,8 +18,11 @@ func TestTsCache(t *testing.T) { h := uint64(75) + a, _ := address.NewFromString("t00") + add := func() { ts, err := types.NewTipSet([]*types.BlockHeader{{ + Miner: a, Height: h, ParentStateRoot: dummyCid, Messages: dummyCid, @@ -54,8 +59,10 @@ func TestTsCacheNulls(t *testing.T) { h := uint64(75) + a, _ := address.NewFromString("t00") add := func() { ts, err := types.NewTipSet([]*types.BlockHeader{{ + Miner: a, Height: h, ParentStateRoot: dummyCid, Messages: dummyCid,