-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds test actions for modifying the block (timestamp and level)
- Loading branch information
Showing
10 changed files
with
165 additions
and
27 deletions.
There are no files selected for viewing
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
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
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,42 @@ | ||
import Blockly from 'blockly'; | ||
|
||
import type { Block } from 'src/typings/blockly'; | ||
import { buildAction } from '@tezwell/tezos-testing-sdk'; | ||
import { ActionKind } from '@tezwell/tezos-testing-sdk/action'; | ||
|
||
import BlockKind from '../enums/BlockKind'; | ||
import Testing from '../generators/Testing'; | ||
import { buildBlockErrorString } from '../utils/errorHandling'; | ||
|
||
const ModifyBlock = { | ||
type: BlockKind.test__modify_block_level, | ||
message0: 'Modify next block level to %1', | ||
args0: [ | ||
{ | ||
type: 'input_value', | ||
name: 'LEVEL', | ||
check: ['Nat'], | ||
}, | ||
], | ||
colour: 300, | ||
}; | ||
|
||
Blockly.Blocks[ModifyBlock.type] = { | ||
init: function () { | ||
this.jsonInit(ModifyBlock); | ||
this.setPreviousStatement(true, ['TestAction']); | ||
this.setNextStatement(true, ['TestAction']); | ||
}, | ||
}; | ||
|
||
Testing.addBlock(ModifyBlock.type, { | ||
toAction: (block: Block) => { | ||
const level = Number(block.getInputTargetBlock('LEVEL')?.getFieldValue('nat_value') || 1); | ||
|
||
if (level < 1 || level > 99999999) { | ||
throw new Error(`The block level must be between 1 and 99999999. ${buildBlockErrorString(block)}`); | ||
} | ||
|
||
return buildAction(ActionKind.ModifyBlockLevel, { level }); | ||
}, | ||
}); |
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,38 @@ | ||
import Blockly from 'blockly'; | ||
|
||
import type { Block } from 'src/typings/blockly'; | ||
import { buildAction } from '@tezwell/tezos-testing-sdk'; | ||
import { ActionKind } from '@tezwell/tezos-testing-sdk/action'; | ||
|
||
import BlockKind from '../enums/BlockKind'; | ||
import Testing from '../generators/Testing'; | ||
import { validateTimestamp } from '../values/Timestamp'; | ||
|
||
const ModifyBlock = { | ||
type: BlockKind.test__modify_block_timestamp, | ||
message0: 'Modify next block timestamp to %1', | ||
args0: [ | ||
{ | ||
type: 'input_value', | ||
name: 'TIMESTAMP', | ||
check: ['Timestamp'], | ||
}, | ||
], | ||
colour: 300, | ||
}; | ||
|
||
Blockly.Blocks[ModifyBlock.type] = { | ||
init: function () { | ||
this.jsonInit(ModifyBlock); | ||
this.setPreviousStatement(true, ['TestAction']); | ||
this.setNextStatement(true, ['TestAction']); | ||
}, | ||
}; | ||
|
||
Testing.addBlock(ModifyBlock.type, { | ||
toAction: (block: Block) => { | ||
const timestamp = validateTimestamp(block.getInputTargetBlock('TIMESTAMP')!); | ||
|
||
return buildAction(ActionKind.ModifyBlockTimestamp, { timestamp }); | ||
}, | ||
}); |
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
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 |
---|---|---|
|
@@ -2041,10 +2041,10 @@ | |
axios "0.26.1" | ||
rxjs "7.5.5" | ||
|
||
"@tezwell/[email protected].17": | ||
version "0.0.17" | ||
resolved "https://registry.yarnpkg.com/@tezwell/tezos-testing-sdk/-/tezos-testing-sdk-0.0.17.tgz#145f2553aa4bbb3bb628eaef1057f096da2286a3" | ||
integrity sha512-ElmAKn7wKVPzGaYjoZABYiLDrfMk7UFRHGKQJn5vcVw1GeriR22BpCabJvcRmAe/9tENt6/Lba4+jIGV3QiNCQ== | ||
"@tezwell/[email protected].18": | ||
version "0.0.18" | ||
resolved "https://registry.yarnpkg.com/@tezwell/tezos-testing-sdk/-/tezos-testing-sdk-0.0.18.tgz#8d9811583b4f62730078ae3b81486fba9288dc52" | ||
integrity sha512-gwhfxrVo/To4eKGFxbwbA+r6j4AQmELjfLx0KrpbQwlmVrnS6SX9Ijsfi2n17OSaCTYk6wlCoP0+1ciD0cYy2A== | ||
|
||
"@tootallnate/once@1": | ||
version "1.1.2" | ||
|