Skip to content

Commit

Permalink
FIP 0085 test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Jun 25, 2024
1 parent be592d8 commit 519e37c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go
github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.14.0-rc1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
github.com/filecoin-project/go-state-types v0.14.0-rc2 h1:jx+iOyy7un1G6ozkvKpIBVFhs6Rg23j6NAoiIjBmGTc=
github.com/filecoin-project/go-state-types v0.14.0-rc2/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk=
Expand Down
72 changes: 72 additions & 0 deletions itests/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
Expand All @@ -17,9 +18,11 @@ import (
miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner"
power11 "github.com/filecoin-project/go-state-types/builtin/v11/power"
adt11 "github.com/filecoin-project/go-state-types/builtin/v11/util/adt"
account "github.com/filecoin-project/go-state-types/builtin/v14/account"
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
migration "github.com/filecoin-project/go-state-types/builtin/v9/migration/test"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"

verifregst "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/manifest"
Expand Down Expand Up @@ -828,3 +831,72 @@ func TestMigrationNV21(t *testing.T) {
//todo @zen Direct data onboarding tests

}

func TestMigrationNV23(t *testing.T) {
kit.QuietMiningLogs()
f090Addr, err := address.NewIDAddress(90)
require.NoError(t, err)
nv23epoch := abi.ChainEpoch(100)
testClient, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
kit.UpgradeSchedule(stmgr.Upgrade{
Network: network.Version22,
Height: -1,
}, stmgr.Upgrade{
Network: network.Version23,
Height: nv23epoch,
Migration: filcns.UpgradeActorsV14,
},
))

ens.InterconnectAll().BeginMining(10 * time.Millisecond)

clientApi := testClient.FullNode.(*impl.FullNodeAPI)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

testClient.WaitTillChain(ctx, kit.HeightAtLeast(nv23epoch+5))

bs := blockstore.NewAPIBlockstore(testClient)
ctxStore := gstStore.WrapBlockStore(ctx, bs)

preMigrationTs, err := clientApi.ChainGetTipSetByHeight(ctx, nv23epoch-1, types.EmptyTSK)
require.NoError(t, err)

root := preMigrationTs.Blocks()[0].ParentStateRoot
preStateTree, err := state.LoadStateTree(ctxStore, root)
require.NoError(t, err)
require.Equal(t, types.StateTreeVersion5, preStateTree.Version())

// Check f090 actor before migration

msigCodeNv22, ok := actors.GetActorCodeID(actorstypes.Version13, manifest.MultisigKey)
assert.True(t, ok)
f090ActorPre, err := preStateTree.GetActor(f090Addr)
require.NoError(t, err)
require.True(t, f090ActorPre.Code.Equals(msigCodeNv22))

// Wait for the migration
testClient.WaitTillChain(ctx, kit.HeightAtLeast(nv23epoch+1))
postMigrationTs, err := clientApi.ChainHead(ctx)
require.NoError(t, err)
postStateTree, err := state.LoadStateTree(ctxStore, postMigrationTs.Blocks()[0].ParentStateRoot)
require.NoError(t, err)

// Check the new system actor
systemAct, err := postStateTree.GetActor(builtin.SystemActorAddr)
require.NoError(t, err)
systemCode, ok := actors.GetActorCodeID(actorstypes.Version14, manifest.SystemKey)
require.True(t, ok)
require.Equal(t, systemCode, systemAct.Code)

// Check f090 actor after migration
f090ActorPost, err := postStateTree.GetActor(f090Addr)
require.NoError(t, err)
accountNV23, ok := actors.GetActorCodeID(actorstypes.Version14, manifest.AccountKey)
assert.True(t, ok)
require.True(t, f090ActorPost.Code.Equals(accountNV23))
f090StatePost, err := clientApi.StateReadState(ctx, f090Addr, types.EmptyTSK)
require.NoError(t, err)
state := f090StatePost.State.(*account.State)
require.Equal(t, state.Address, f090Addr)
}

0 comments on commit 519e37c

Please sign in to comment.