Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Added checkStateInvariants (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball authored Feb 8, 2022
1 parent 8071714 commit b263592
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions actors/migration/nv15/test/miner_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ package test

import (
"context"
"strings"

"github.com/filecoin-project/specs-actors/v7/actors/builtin"
"github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
"github.com/filecoin-project/specs-actors/v7/actors/states"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/rt"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"

ipld2 "github.com/filecoin-project/specs-actors/v2/support/ipld"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power"
"github.com/filecoin-project/specs-actors/v6/actors/util/adt"
vm6 "github.com/filecoin-project/specs-actors/v6/support/vm"
power7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power"
vm7 "github.com/filecoin-project/specs-actors/v7/support/vm"

"github.com/filecoin-project/specs-actors/v7/actors/builtin"
"github.com/filecoin-project/specs-actors/v7/actors/builtin/exported"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
power7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power"
"github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
"github.com/filecoin-project/specs-actors/v7/actors/migration/nv15"
"github.com/filecoin-project/specs-actors/v7/support/ipld"
vm7 "github.com/filecoin-project/specs-actors/v7/support/vm"
"github.com/filecoin-project/specs-actors/v7/support/vm6Util"

"testing"
Expand Down Expand Up @@ -146,7 +148,7 @@ func createMinersAndSectorsV6(t *testing.T, ctx context.Context, ctxStore adt.St

func TestNv15Migration(t *testing.T) {
ctx := context.Background()
bs := ipld2.NewSyncBlockStoreInMemory()
bs := ipld.NewBlockStoreInMemory()
v := vm6.NewVMWithSingletons(ctx, t, bs)
ctxStore := adt.WrapBlockStore(ctx, bs)
log := nv15.TestLogger{TB: t}
Expand Down Expand Up @@ -189,6 +191,14 @@ func TestNv15Migration(t *testing.T) {
networkStatsAfter := vm7.GetNetworkStats(t, v7)
compareNetworkStats(t, networkStatsBefore, networkStatsAfter)

stateTree, err := v7.GetStateTree()
require.NoError(t, err)
totalBalance, err := v7.GetTotalActorBalance()
require.NoError(t, err)
acc, err := states.CheckStateInvariants(stateTree, totalBalance, v7.GetEpoch()-1)
require.NoError(t, err)
require.True(t, acc.IsEmpty(), strings.Join(acc.Messages(), "\n"))

// Compare miner states
for _, minerInfo := range minerInfos {
var oldMinerState miner6.State
Expand Down

0 comments on commit b263592

Please sign in to comment.