Skip to content

Commit

Permalink
add tests for PlanetA conditions (#291)
Browse files Browse the repository at this point in the history
* add tests for PlanetA conditions

* updated commit hash

* update leap-core
  • Loading branch information
johannbarbie authored Jul 12, 2019
1 parent c98b21e commit 8bd222e
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"jayson": "^2.0.6",
"jsbi-utils": "^1.0.0",
"jsondiffpatch": "^0.2.5",
"leap-core": "0.32.0",
"leap-core": "0.32.4",
"level": "^4.0.0",
"lodash": "^4.17.10",
"lodash.get": "^4.4.2",
Expand Down
27 changes: 15 additions & 12 deletions src/tx/applyTx/checkSpendCond.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,9 @@ module.exports = async (state, tx, bridgeState, nodeConfig = {}) => {
let allowance;

if (!spendingIsOwner) {
if (unspent.address !== input.signer) {
if (input.signer && unspent.address !== input.signer) {
throw new Error(
`output owner ${unspent.address} unequal input signer: ${
input.signer
}`
`output owner ${unspent.address} unequal input signer: ${input.signer}`
);
}
allowance = {};
Expand Down Expand Up @@ -393,16 +391,21 @@ module.exports = async (state, tx, bridgeState, nodeConfig = {}) => {
});
});

const evmResult = await runTx(vm, {
nonce: nonceCounter,
gasLimit: GAS_LIMIT_HEX, // TODO: set gas Limit to (inputs - outputs) / gasPrice
to: sigHashBuf,
// NOPE: the plasma address is replaced with sighash, to prevent replay attacks
data: spendingInput.msgData,
});
let evmResult;

const logOuts = [];
try {
evmResult = await runTx(vm, {
nonce: nonceCounter,
gasLimit: GAS_LIMIT_HEX, // TODO: set gas Limit to (inputs - outputs) / gasPrice
to: sigHashBuf,
// NOPE: the plasma address is replaced with sighash, to prevent replay attacks
data: spendingInput.msgData,
});
} catch (err) {
console.log(err);
}

const logOuts = [];
// iterate through all events
evmResult.vm.logs.forEach(log => {
const originAddr = `0x${log[0].toString('hex')}`;
Expand Down
Loading

0 comments on commit 8bd222e

Please sign in to comment.