From 1baff04e7b37a62f7546ae235ab092c99edde82c Mon Sep 17 00:00:00 2001 From: dustinxie Date: Mon, 2 Dec 2024 22:07:30 -0800 Subject: [PATCH] [factory] fix statedb WorkingSetAtHeight (#4511) --- blockchain/integrity/integrity_test.go | 4 ++-- state/factory/factory_test.go | 2 +- state/factory/statedb.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/integrity/integrity_test.go b/blockchain/integrity/integrity_test.go index dd11ce6834..ad47ed0360 100644 --- a/blockchain/integrity/integrity_test.go +++ b/blockchain/integrity/integrity_test.go @@ -2356,7 +2356,7 @@ func testHistoryForAccount(t *testing.T, statetx bool) { // check history account's balance if statetx { _, err = sf.WorkingSetAtHeight(ctx, 0) - require.Equal(factory.ErrNotSupported, errors.Cause(err)) + require.NoError(err) } else { sr, err := sf.WorkingSetAtHeight(ctx, bc.TipHeight()-1) require.NoError(err) @@ -2404,7 +2404,7 @@ func testHistoryForContract(t *testing.T, statetx bool) { // check the the original balance again if statetx { _, err = sf.WorkingSetAtHeight(ctx, bc.TipHeight()-1) - require.Equal(factory.ErrNotSupported, errors.Cause(err)) + require.NoError(err) } else { sr, err := sf.WorkingSetAtHeight(ctx, bc.TipHeight()-1) require.NoError(err) diff --git a/state/factory/factory_test.go b/state/factory/factory_test.go index 18888766e2..d6f4b8d204 100644 --- a/state/factory/factory_test.go +++ b/state/factory/factory_test.go @@ -575,7 +575,7 @@ func testHistoryState(sf Factory, t *testing.T, statetx, archive bool) { if statetx { // statetx not support archive mode yet _, err = sf.WorkingSetAtHeight(ctx, 0) - require.Equal(t, ErrNotSupported, errors.Cause(err)) + require.NoError(t, err) } else { _, err = sf.WorkingSetAtHeight(ctx, 10) if !archive { diff --git a/state/factory/statedb.go b/state/factory/statedb.go index ddfb2810d0..5dc4e08176 100644 --- a/state/factory/statedb.go +++ b/state/factory/statedb.go @@ -268,7 +268,7 @@ func (sdb *stateDB) WorkingSet(ctx context.Context) (protocol.StateManager, erro func (sdb *stateDB) WorkingSetAtHeight(ctx context.Context, height uint64) (protocol.StateManager, error) { // TODO: implement archive mode - return nil, ErrNotSupported + return sdb.newWorkingSet(ctx, height) } // PutBlock persists all changes in RunActions() into the DB