mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
tests/solidity: Added in more op code tests and unit tests
This commit is contained in:
parent
cd41653166
commit
98a1598e6d
2 changed files with 36 additions and 10 deletions
|
|
@ -105,6 +105,24 @@ contract OpCodes {
|
|||
//signextend
|
||||
assembly { pop(signextend(1, 10)) }
|
||||
|
||||
//sha3
|
||||
assembly { pop(calldataload(0)) }
|
||||
|
||||
//blockhash
|
||||
assembly { pop(blockhash(sub(number(), 1))) }
|
||||
|
||||
//balance
|
||||
assembly { pop(balance(0x0)) }
|
||||
|
||||
//caller
|
||||
assembly { pop(caller()) }
|
||||
|
||||
//codesize
|
||||
assembly { pop(codesize()) }
|
||||
|
||||
//extcodesize
|
||||
assembly { pop(extcodesize(0x1)) }
|
||||
|
||||
//origin
|
||||
assembly { pop(origin()) }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,26 @@ contract('OpCodes', (accounts) => {
|
|||
beforeEach(async () => {
|
||||
contractInstance = await TodoList.deployed()
|
||||
})
|
||||
it('should add a to-do note successfully with a short text of 20 letters', async () => {
|
||||
it('Should run without errors the majorit of opcodes', async () => {
|
||||
await contractInstance.test()
|
||||
// await contractInstance.test_revert()
|
||||
// await contractInstance.test_invalid()
|
||||
await contractInstance.test_stop()
|
||||
|
||||
})
|
||||
// it('should mark one of your to-dos as completed', async () => {
|
||||
// await contractInstance.addTodo('example')
|
||||
// await contractInstance.markTodoAsCompleted(0)
|
||||
// const lastTodoAdded = await contractInstance.todos(accounts[0], 0)
|
||||
// const isTodoCompleted = lastTodoAdded[3] // 3 is the bool isCompleted value of the todo note
|
||||
// assert(isTodoCompleted, 'The todo should be true as completed')
|
||||
// })
|
||||
|
||||
it('Should throw invalid op code', async () => {
|
||||
try{
|
||||
await contractInstance.test_invalid()
|
||||
}
|
||||
catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
|
||||
it('Should revert', async () => {
|
||||
try{
|
||||
await contractInstance.test_revert() }
|
||||
catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue