-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ar-io/PE-6314-evolve-ant
feat(evolve): prepend evolve handler to set txid on eval handler
- Loading branch information
Showing
5 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
changelogs/2024-07-12-Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
### Added | ||
|
||
- Evolve capabilities and handlers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Changelog | ||
|
||
### Added | ||
|
||
- Feature A | ||
- Feature B | ||
|
||
### Changed | ||
|
||
- Updated component X to use Y. | ||
|
||
### Fixed | ||
|
||
- Bug in module Z. | ||
|
||
### Deprecated | ||
|
||
- Handler X is deprecated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { createAntAosLoader } = require('./utils'); | ||
const { describe, it } = require('node:test'); | ||
const assert = require('node:assert'); | ||
const { | ||
AO_LOADER_HANDLER_ENV, | ||
DEFAULT_HANDLE_OPTIONS, | ||
STUB_ADDRESS, | ||
BUNDLED_AOS_ANT_LUA, | ||
} = require('../tools/constants'); | ||
|
||
describe('aos Evolve', async () => { | ||
const { handle: originalHandle, memory: startMemory } = | ||
await createAntAosLoader(); | ||
|
||
async function handle(options = {}, mem = startMemory) { | ||
return originalHandle( | ||
mem, | ||
{ | ||
...DEFAULT_HANDLE_OPTIONS, | ||
...options, | ||
}, | ||
AO_LOADER_HANDLER_ENV, | ||
); | ||
} | ||
|
||
it('should evolve the ant', async () => { | ||
const srcCodeTxIdStub = ''.padEnd(43, '123-test'); | ||
const evolveResult = await handle({ | ||
Tags: [ | ||
{ name: 'Action', value: 'Eval' }, | ||
{ name: 'Source-Code-TX-ID', value: srcCodeTxIdStub }, | ||
], | ||
Data: BUNDLED_AOS_ANT_LUA, | ||
}); | ||
|
||
const result = await handle( | ||
{ | ||
Tags: [{ name: 'Action', value: 'Info' }], | ||
}, | ||
evolveResult.Memory, | ||
); | ||
|
||
const state = JSON.parse(result.Messages[0].Data); | ||
assert(state); | ||
assert(state['Source-Code-TX-ID'] === srcCodeTxIdStub); | ||
}); | ||
|
||
it('should not evolve the ant', async () => { | ||
const evolveResult = await handle({ | ||
Tags: [ | ||
{ name: 'Action', value: 'Eval' }, | ||
// omit src code id | ||
], | ||
Data: BUNDLED_AOS_ANT_LUA, | ||
}); | ||
|
||
const result = await handle( | ||
{ | ||
Tags: [{ name: 'Action', value: 'Info' }], | ||
}, | ||
evolveResult.Memory, | ||
); | ||
|
||
const state = JSON.parse(result.Messages[0].Data); | ||
assert(state); | ||
assert(state['Source-Code-TX-ID'] === '__INSERT_SOURCE_CODE_ID__'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters