Skip to content

Commit

Permalink
node: SupplyManager restared by SetHead API call
Browse files Browse the repository at this point in the history
  • Loading branch information
blukat29 committed Aug 13, 2024
1 parent e077455 commit 2ce37f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions node/cn/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (b *CNAPIBackend) SetHead(number uint64) error {
b.cn.protocolManager.Downloader().Cancel()
b.cn.protocolManager.SetSyncStop(true)
defer b.cn.protocolManager.SetSyncStop(false)
b.cn.supplyManager.Stop()
defer b.cn.supplyManager.Start()
return doSetHead(b.cn.blockchain, b.cn.engine, b.cn.governance, b.gpo, number)
}

Expand Down
13 changes: 13 additions & 0 deletions node/cn/api_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ func testGov() *governance.MixedEngine {
return governance.NewMixedEngine(config, db)
}

type testSupplyManager struct{}

func (sm *testSupplyManager) Start() {
}

func (sm *testSupplyManager) Stop() {
}

func (sm *testSupplyManager) GetTotalSupply(num uint64) (*reward.TotalSupply, error) {
return &reward.TotalSupply{}, nil
}

func TestCNAPIBackend_SetHead(t *testing.T) {
mockCtrl, mockBlockChain, _, api := newCNAPIBackend(t)
defer mockCtrl.Finish()
Expand All @@ -183,6 +195,7 @@ func TestCNAPIBackend_SetHead(t *testing.T) {
api.cn.protocolManager = pm
api.cn.engine = gxhash.NewFullFaker()
api.cn.governance = testGov()
api.cn.supplyManager = &testSupplyManager{}
api.gpo = gasprice.NewOracle(api, gasprice.Config{}, nil, api.cn.governance)

number := uint64(123)
Expand Down

0 comments on commit 2ce37f0

Please sign in to comment.