Skip to content

Commit

Permalink
add e2etest for migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Jun 12, 2024
1 parent 1de44c9 commit 0ca40b9
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 7 deletions.
3 changes: 2 additions & 1 deletion e2etest/e2etest.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,18 @@ func (e *e2etest) runCase(ctx context.Context, c *testcase) {
func (e *e2etest) teardown() {
require := require.New(e.t)
// clean up
require.NoError(e.svr.Stop(context.Background()))
testutil.CleanupPath(e.cfg.Chain.ChainDBPath)
testutil.CleanupPath(e.cfg.Chain.TrieDBPath)
testutil.CleanupPath(e.cfg.Chain.BloomfilterIndexDBPath)
testutil.CleanupPath(e.cfg.Chain.CandidateIndexDBPath)
testutil.CleanupPath(e.cfg.Chain.StakingIndexDBPath)
testutil.CleanupPath(e.cfg.Chain.ContractStakingIndexDBPath)
testutil.CleanupPath(e.cfg.Chain.ContractStakingIndexDBPathV2)
testutil.CleanupPath(e.cfg.DB.DbPath)
testutil.CleanupPath(e.cfg.Chain.IndexDBPath)
testutil.CleanupPath(e.cfg.System.SystemLogDBPath)
testutil.CleanupPath(e.cfg.Chain.SGDIndexDBPath)
require.NoError(e.svr.Stop(context.Background()))
}

func (e *e2etest) withTest(t *testing.T) *e2etest {
Expand Down
13 changes: 11 additions & 2 deletions e2etest/expect.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type (
bucketExpect struct {
bucket *iotextypes.VoteBucket
}
executionExpect struct {
contractAddress string
}
)

func (be *basicActionExpect) expect(test *e2etest, act *action.SealedEnvelope, receipt *action.Receipt, err error) {
Expand Down Expand Up @@ -78,7 +81,7 @@ func (ce *candidateExpect) expect(test *e2etest, act *action.SealedEnvelope, rec
func (be *bucketExpect) expect(test *e2etest, act *action.SealedEnvelope, receipt *action.Receipt, err error) {
require := require.New(test.t)
method := &iotexapi.ReadStakingDataMethod{
Method: iotexapi.ReadStakingDataMethod_BUCKETS_BY_INDEXES,
Method: iotexapi.ReadStakingDataMethod_COMPOSITE_BUCKETS_BY_INDEXES,
}
methodBytes, err := proto.Marshal(method)
require.NoError(err)
Expand Down Expand Up @@ -110,6 +113,12 @@ func (be *bucketExpect) expect(test *e2etest, act *action.SealedEnvelope, receip
idx := slices.IndexFunc(vbs.Buckets, func(vb *iotextypes.VoteBucket) bool {
return vb.ContractAddress == be.bucket.ContractAddress
})
require.True(idx != -1)
require.Greater(idx, -1)
require.EqualValues(be.bucket.String(), vbs.Buckets[idx].String())
}

func (ee *executionExpect) expect(test *e2etest, act *action.SealedEnvelope, receipt *action.Receipt, err error) {
require := require.New(test.t)
require.NoError(err)
require.Equal(ee.contractAddress, receipt.ContractAddress)
}
Loading

0 comments on commit 0ca40b9

Please sign in to comment.