diff --git a/.github/workflows/ant.yaml b/.github/workflows/ant.yaml index ea8e503..fb44554 100644 --- a/.github/workflows/ant.yaml +++ b/.github/workflows/ant.yaml @@ -29,6 +29,8 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} + # TODO: add ar-io-sdk e2e tests against lua code to be bundled on changes (e.g. create a new ant, publish it and validate it works with the sdk) + integration: runs-on: ubuntu-latest steps: @@ -41,3 +43,32 @@ jobs: - run: yarn --frozen-lockfile - run: yarn aos:build - run: yarn test + + notify: + runs-on: ubuntu-latest + needs: [unit, integration] + if: always() + steps: + - name: Notify Slack on Success + if: success() && github.ref == 'refs/heads/main' && needs.unit.result == 'success' && needs.integration.result == 'success' + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + text: | + Unit Tests: ${{ needs.unit.result }} + Integration Tests: ${{ needs.integration.result }} + fields: repo,message,commit,author,action,eventName,ref,workflow,job + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Notify Slack on Failure + if: failure() + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + text: | + Unit Tests: ${{ needs.unit.result }} + Integration Tests: ${{ needs.integration.result }} + fields: repo,message,commit,author,action,eventName,ref,workflow,job + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/package.json b/package.json index 9ae4c01..9ba0f66 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "aos:publish": "node tools/bundle-aos.js && node tools/publish-aos.js", "aos:load": "node tools/bundle-aos.js && node tools/load-aos.js", "aos:spawn": "node tools/spawn-aos.js", - "test": "node --test --test-concurrency 1 --experimental-wasm-memory64 **/*.test.js" + "test": "yarn aos:build && node --test --test-concurrency 1 --experimental-wasm-memory64 **/*.test.js" }, "devDependencies": { "prettier": "^3.3.2", diff --git a/src/common/main.lua b/src/common/main.lua index 825dfc2..38a30bd 100644 --- a/src/common/main.lua +++ b/src/common/main.lua @@ -160,7 +160,7 @@ function ant.init() Logo = Logo, Denomination = tostring(Denomination), Owner = Owner, - HandlerNames = utils.getHandlerNames(Handlers), + Handlers = utils.getHandlerNames(Handlers), ["Source-Code-TX-ID"] = SourceCodeTxId, } ao.send({ diff --git a/test/balances.test.js b/test/balances.test.js index 31b1b4e..5e76c67 100644 --- a/test/balances.test.js +++ b/test/balances.test.js @@ -22,7 +22,7 @@ describe('aos Balances', async () => { ); } - it('Should fetch the owner balance', async () => { + it('should fetch the owner balance', async () => { const result = await handle({ Tags: [ { name: 'Action', value: 'Balance' }, @@ -33,7 +33,7 @@ describe('aos Balances', async () => { const ownerBalance = result.Messages[0].Data; assert(ownerBalance === 1); }); - it('Should fetch the balances of the ANT', async () => { + it('should fetch the balances of the ANT', async () => { const result = await handle({ Tags: [{ name: 'Action', value: 'Balances' }], }); @@ -47,7 +47,7 @@ describe('aos Balances', async () => { assert(ownerBalance === 1); }); - it('Should transfer the ANT', async () => { + it('should transfer the ANT', async () => { const recipient = ''.padEnd(43, '2'); const transferResult = await handle({ Tags: [ @@ -67,7 +67,7 @@ describe('aos Balances', async () => { assert(balances[recipient] === 1); }); - it('Should send credit and debit notice on transfer', async () => { + it('should send credit and debit notice on transfer', async () => { const recipient = ''.padEnd(43, '2'); const transferResult = await handle({ Tags: [ diff --git a/test/controllers.test.js b/test/controllers.test.js index 2a91e51..948b2e2 100644 --- a/test/controllers.test.js +++ b/test/controllers.test.js @@ -22,7 +22,7 @@ describe('aos Controllers', async () => { ); } - it('Should get the controllers', async () => { + it('should get the controllers', async () => { const result = await handle({ Tags: [{ name: 'Action', value: 'Controllers' }], }); @@ -32,7 +32,7 @@ describe('aos Controllers', async () => { assert(controllers.includes(STUB_ADDRESS)); }); - it('Should add the controller', async () => { + it('should add the controller', async () => { const controller = ''.padEnd(43, '2'); const result = await handle({ Tags: [ @@ -44,7 +44,7 @@ describe('aos Controllers', async () => { assert(JSON.parse(result.Messages[0].Data).includes(controller), true); }); - it('Should remove the controller', async () => { + it('should remove the controller', async () => { const result = await handle({ Tags: [ { name: 'Action', value: 'Remove-Controller' }, diff --git a/test/info.test.js b/test/info.test.js index 518c642..b3a9994 100644 --- a/test/info.test.js +++ b/test/info.test.js @@ -22,7 +22,7 @@ describe('aos Info', async () => { ); } - it('Should get the process info', async () => { + it('should get the process info', async () => { const result = await handle({ Tags: [{ name: 'Action', value: 'Info' }], }); @@ -34,9 +34,31 @@ describe('aos Info', async () => { assert(processInfo.Denomination !== undefined); assert(processInfo.Logo); assert(processInfo.Owner); + assert(processInfo.Handlers); + assert.deepStrictEqual(processInfo.Handlers, [ + 'evolve', + '_eval', + '_default', + 'transfer', + 'balance', + 'balances', + 'totalSupply', + 'info', + 'addController', + 'removeController', + 'controllers', + 'setRecord', + 'removeRecord', + 'record', + 'records', + 'setName', + 'setTicker', + 'initializeState', + 'state', + ]); }); - it('Should set the name of the process', async () => { + it('should set the name of the process', async () => { const setNameResult = await handle({ Tags: [ { name: 'Action', value: 'Set-Name' }, @@ -54,7 +76,7 @@ describe('aos Info', async () => { assert(info.Name === 'Test Process'); }); - it('Should set the ticker of the process', async () => { + it('should set the ticker of the process', async () => { const setTickerResult = await handle({ Tags: [ { name: 'Action', value: 'Set-Ticker' }, diff --git a/test/initialize.test.js b/test/initialize.test.js index 3b83629..806a7dc 100644 --- a/test/initialize.test.js +++ b/test/initialize.test.js @@ -22,7 +22,7 @@ describe('aos Initialization', async () => { ); } - it('Should initialize the state of the ant', async () => { + it('should initialize the state of the ant', async () => { const antState = { name: 'Test Process', ticker: 'TEST', diff --git a/test/records.test.js b/test/records.test.js index d8074a9..06a2631 100644 --- a/test/records.test.js +++ b/test/records.test.js @@ -22,7 +22,7 @@ describe('aos Records', async () => { ); } - it('Should get the records of the ant', async () => { + it('should get the records of the ant', async () => { const result = await handle({ Tags: [{ name: 'Action', value: 'Records' }], }); @@ -32,7 +32,7 @@ describe('aos Records', async () => { assert(records['@']); }); - it('Should get a singular record of the ant', async () => { + it('should get a singular record of the ant', async () => { const result = await handle({ Tags: [ { name: 'Action', value: 'Record' }, @@ -46,7 +46,7 @@ describe('aos Records', async () => { assert(record.ttlSeconds); }); - it('Should set the record of an ANT', async () => { + it('should set the record of an ANT', async () => { const setRecordResult = await handle({ Tags: [ { name: 'Action', value: 'Set-Record' }, @@ -68,7 +68,7 @@ describe('aos Records', async () => { assert(record.ttlSeconds === 3600); }); - it('Should remove the record of an ANT', async () => { + it('should remove the record of an ANT', async () => { const setRecordResult = await handle({ Tags: [ { name: 'Action', value: 'Set-Record' }, diff --git a/test/registry.test.js b/test/registry.test.js index b1126f6..ceb3640 100644 --- a/test/registry.test.js +++ b/test/registry.test.js @@ -24,7 +24,7 @@ describe('Registry Updates', async () => { ); } - it('Should send update to registry when a controller is added', async () => { + it('should send update to registry when a controller is added', async () => { const result = await handle({ Tags: [ { name: 'Action', value: 'Add-Controller' }, @@ -44,7 +44,7 @@ describe('Registry Updates', async () => { assert(notifyMessage, 'State-Notice message not found'); }); - it('Should send update to registry when a controller is removed', async () => { + it('should send update to registry when a controller is removed', async () => { await handle({ Tags: [ { name: 'Action', value: 'Add-Controller' }, @@ -71,7 +71,7 @@ describe('Registry Updates', async () => { assert(notifyMessage, 'State-Notice message not found'); }); - it('Should send update to registry when ANT is transferred', async () => { + it('should send update to registry when ANT is transferred', async () => { const result = await handle({ Tags: [ { name: 'Action', value: 'Transfer' },