diff --git a/libs/SmartContracts.js b/libs/SmartContracts.js index a2b14249..e5da388b 100644 --- a/libs/SmartContracts.js +++ b/libs/SmartContracts.js @@ -264,13 +264,25 @@ class SmartContracts { if (contractTicks.find(t => t.contract === contractName && t.action === tickAction)) { return { logs: { errors: ['contract tick already registered'] } }; } - contractTicks.push({ + const newContractTick = { contract: contractName, action: tickAction, startRefBlock: refHiveBlockNumber + 1, - }); + }; + contractTicks.push(newContractTick); await database.updateContractsConfig(contractsConfig); - return { logs: { errors: [], events: [] } }; + return { + logs: { + errors: [], + events: [ + { + contract: 'contract', + event: 'registerTick', + data: newContractTick, + }, + ], + }, + }; } catch (e) { return { logs: { errors: [`${e.name}: ${e.message}`] } }; } diff --git a/test/ticks.js b/test/ticks.js index 2addfc53..fe142c02 100644 --- a/test/ticks.js +++ b/test/ticks.js @@ -166,6 +166,10 @@ describe('ticks', function () { await fixture.sendBlock(block); await tableAsserts.assertNoErrorInLastBlock(); + let res = await fixture.database.getLatestBlockInfo(); + let txs = res.transactions; + assert.equal(txs[1].logs, `{"events":[{"contract":"contract","event":"registerTick","data":{"contract":"testtick","action":"tick","startRefBlock":${refBlockNumber + 1}}}]}`); + refBlockNumber = fixture.getNextRefBlockNumber(); const tickedActions = await getTickingActionsAtRefblock(refBlockNumber); assert.equal(JSON.stringify(tickedActions), '["testtick.tick"]');