Skip to content

Commit

Permalink
Merge pull request #5 from sebaponti/notarize_tx_test
Browse files Browse the repository at this point in the history
Added NotarizeTx Unit Test
  • Loading branch information
maxidev committed May 8, 2018
2 parents 5786992 + 2186b91 commit 8ed226b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/NotarizeTx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const NotarizeTx = artifacts.require('NotarizeTx');

contract('NoterizeTx', addresses => {
let instance;

const bsgNode = addresses[0]
const buyer = addresses[1];
const seller = addresses[2];

const id = '0x7dcb9dc898f40000000000000000000000000000000000000000000000000000';
const date = Date.now();
const value = 10;
const hash = '0x3759835380000000000000000000000000000000000000000000000000000000';
const status = 'status';
const shipping = 'shipping';

beforeEach(async() => {
instance = (await NotarizeTx.new(buyer, seller, id, date, value, hash, status, shipping, {from: bsgNode})).contract;
});

it('should not update the notarize status if sender is not the buyer or bsg_node', async() => {
try {
await instance.updateStatus('status', hash, id, {from: seller});
assert(false, 'It should have failed because a seller cannot update a status.');
} catch(error) {
assert(error.message.includes("revert"));
}
});

it('should not update the notarize shipping if sender is not the buyer or bsg_node', async() => {
try {
await instance.updateShipping('shipping', hash, id, {from: seller});
assert(false, 'It should have failed because a seller cannot update a shipping.');
} catch(error) {
assert(error.message.includes("revert"));
}
});

});

0 comments on commit 8ed226b

Please sign in to comment.