Skip to content

Commit

Permalink
OpCodes: extend MODPOW tests with negative base/exp/mod (#3557)
Browse files Browse the repository at this point in the history
We need to ensure that NeoGo VM behaviour is compatible, ref.
nspcc-dev/neo-go#3649.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Co-authored-by: Shargon <shargon@gmail.com>
  • Loading branch information
AnnaShaleva and shargon authored Oct 29, 2024
1 parent 7f55040 commit 03ba1dc
Showing 1 changed file with 344 additions and 0 deletions.
344 changes: 344 additions & 0 deletions tests/Neo.VM.Tests/Tests/OpCodes/Arithmetic/MODPOW.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,350 @@
}
}
]
},
{
"name": "(3 ^ 4) % 5 == 1",
"script": [
"PUSH3",
"PUSH4",
"PUSH5",
"MODPOW"
],
"steps": [
{
"actions": [
"stepInto",
"stepInto",
"stepInto"
],
"result": {
"state": "BREAK",
"invocationStack": [
{
"instructionPointer": 3,
"nextInstruction": "MODPOW",
"evaluationStack": [
{
"type": "Integer",
"value": 5
},
{
"type": "Integer",
"value": 4
},
{
"type": "Integer",
"value": 3
}
]
}
]
}
},
{
"actions": [
"execute"
],
"result": {
"state": "HALT",
"invocationStack": [],
"resultStack": [
{
"type": "Integer",
"value": 1
}
]
}
}
]
},
{
"name": "(-1 ^ 3) % 3 == -1",
"script": [
"PUSHM1",
"PUSH3",
"PUSH3",
"MODPOW"
],
"steps": [
{
"actions": [
"stepInto",
"stepInto",
"stepInto"
],
"result": {
"state": "BREAK",
"invocationStack": [
{
"instructionPointer": 3,
"nextInstruction": "MODPOW",
"evaluationStack": [
{
"type": "Integer",
"value": 3
},
{
"type": "Integer",
"value": 3
},
{
"type": "Integer",
"value": -1
}
]
}
]
}
},
{
"actions": [
"execute"
],
"result": {
"state": "HALT",
"invocationStack": [],
"resultStack": [
{
"type": "Integer",
"value": -1
}
]
}
}
]
},
{
"name": "(-1 ^ 3) % -3 == -1",
"script": [
"PUSHM1",
"PUSH3",
"PUSH3",
"NEGATE",
"MODPOW"
],
"steps": [
{
"actions": [
"stepInto",
"stepInto",
"stepInto",
"stepInto"
],
"result": {
"state": "BREAK",
"invocationStack": [
{
"instructionPointer": 4,
"nextInstruction": "MODPOW",
"evaluationStack": [
{
"type": "Integer",
"value": -3
},
{
"type": "Integer",
"value": 3
},
{
"type": "Integer",
"value": -1
}
]
}
]
}
},
{
"actions": [
"execute"
],
"result": {
"state": "HALT",
"invocationStack": [],
"resultStack": [
{
"type": "Integer",
"value": -1
}
]
}
}
]
},
{
"name": "(-3 ^ 5) % -5 == -3",
"script": [
"PUSH3",
"NEGATE",
"PUSH5",
"PUSH5",
"NEGATE",
"MODPOW"
],
"steps": [
{
"actions": [
"stepInto",
"stepInto",
"stepInto",
"stepInto",
"stepInto"
],
"result": {
"state": "BREAK",
"invocationStack": [
{
"instructionPointer": 5,
"nextInstruction": "MODPOW",
"evaluationStack": [
{
"type": "Integer",
"value": -5
},
{
"type": "Integer",
"value": 5
},
{
"type": "Integer",
"value": -3
}
]
}
]
}
},
{
"actions": [
"execute"
],
"result": {
"state": "HALT",
"invocationStack": [],
"resultStack": [
{
"type": "Integer",
"value": -3
}
]
}
}
]
},
{
"name": "(3 ^ 4) % -5 == 1",
"script": [
"PUSH3",
"PUSH4",
"PUSH5",
"NEGATE",
"MODPOW"
],
"steps": [
{
"actions": [
"stepInto",
"stepInto",
"stepInto",
"stepInto"
],
"result": {
"state": "BREAK",
"invocationStack": [
{
"instructionPointer": 4,
"nextInstruction": "MODPOW",
"evaluationStack": [
{
"type": "Integer",
"value": -5
},
{
"type": "Integer",
"value": 4
},
{
"type": "Integer",
"value": 3
}
]
}
]
}
},
{
"actions": [
"execute"
],
"result": {
"state": "HALT",
"invocationStack": [],
"resultStack": [
{
"type": "Integer",
"value": 1
}
]
}
}
]
},
{
"name": "(5 ^ -1) % 4 == 1",
"script": [
"PUSH5",
"PUSHM1",
"PUSH4",
"MODPOW"
],
"steps": [
{
"actions": [
"stepInto",
"stepInto",
"stepInto"
],
"result": {
"state": "BREAK",
"invocationStack": [
{
"instructionPointer": 3,
"nextInstruction": "MODPOW",
"evaluationStack": [
{
"type": "Integer",
"value": 4
},
{
"type": "Integer",
"value": -1
},
{
"type": "Integer",
"value": 5
}
]
}
]
}
},
{
"actions": [
"execute"
],
"result": {
"state": "HALT",
"invocationStack": [],
"resultStack": [
{
"type": "Integer",
"value": 1
}
]
}
}
]
}
]
}

0 comments on commit 03ba1dc

Please sign in to comment.