Skip to content

Commit

Permalink
test: fix failing tests for #1214
Browse files Browse the repository at this point in the history
  • Loading branch information
phra committed Dec 21, 2017
1 parent f7f687d commit 440285e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
31 changes: 15 additions & 16 deletions test/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2816,26 +2816,26 @@ var runTests = function(contractFactory) {
describe('typical usage', function() {
runTests(getEthContractInstance);

it('should deploy a contract, sign transaction, and return contract instance', function (done) {
it('should deploy a contract, sign transaction, and return contract instance', void async function (done) {
var provider = new FakeIpcProvider();
var eth = new Eth(provider);
eth.accounts.wallet.add(account.privateKey);

provider.injectValidation(function (payload) {

var expected = eth.accounts.wallet[0].signTransaction({
data: '0x1234567000000000000000000000000' + account.address.toLowerCase().replace('0x', '') + '00000000000000000000000000000000000000000000000000000000000000c8',
from: account.address.toLowerCase(),
gas: '0xc350',
gasPrice: '0xbb8',
chainId: '0x1',
nonce: '0x1',
}).rawTransaction;

assert.equal(payload.method, 'eth_sendRawTransaction');
assert.deepEqual(payload.params, [expected]);
await ((async () => {
provider.injectValidation(async function (payload) {
var expected = (await eth.accounts.wallet[0].signTransaction({
data: '0x1234567000000000000000000000000' + account.address.toLowerCase().replace('0x', '') + '00000000000000000000000000000000000000000000000000000000000000c8',
from: account.address.toLowerCase(),
gas: '0xc350',
gasPrice: '0xbb8',
chainId: '0x1',
nonce: '0x1',
})).rawTransaction;

});
assert.equal(payload.method, 'eth_sendRawTransaction');
assert.deepEqual(payload.params, [expected]);
});
})());
provider.injectResult('0x5550000000000000000000000000000000000000000000000000000000000032');

provider.injectValidation(function (payload) {
Expand All @@ -2844,7 +2844,6 @@ describe('typical usage', function() {
});
provider.injectResult(null);


provider.injectValidation(function (payload) {
assert.equal(payload.method, 'eth_subscribe');
assert.deepEqual(payload.params, ['newHeads']);
Expand Down
12 changes: 6 additions & 6 deletions test/eth.accounts.signTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ describe("eth", function () {

// For each test
tests.forEach(function (test, i) {
it("signTransaction must compare to eth_signTransaction", function() {
it("signTransaction must compare to eth_signTransaction", async function() {
var ethAccounts = new Accounts();

var testAccount = ethAccounts.privateKeyToAccount(test.privateKey);
assert.equal(testAccount.address, test.address);

var tx = testAccount.signTransaction(test.transaction);
var tx = await testAccount.signTransaction(test.transaction);

assert.equal(tx.rawTransaction, test.rawTransaction);
});
});

tests.forEach(function (test, i) {
it("signTransaction using the iban as \"to\" must compare to eth_signTransaction", function() {
it("signTransaction using the iban as \"to\" must compare to eth_signTransaction", async function() {
var ethAccounts = new Accounts();

var testAccount = ethAccounts.privateKeyToAccount(test.privateKey);
Expand All @@ -73,7 +73,7 @@ describe("eth", function () {
var transaction = clone(test.transaction);
transaction.to = transaction.toIban;
delete transaction.toIban;
var tx = testAccount.signTransaction(transaction);
var tx = await testAccount.signTransaction(transaction);

assert.equal(tx.rawTransaction, test.rawTransaction);
});
Expand Down Expand Up @@ -207,13 +207,13 @@ describe("eth", function () {
});

tests.forEach(function (test, i) {
it("recoverTransaction, must recover signature", function() {
it("recoverTransaction, must recover signature", async function() {
var ethAccounts = new Accounts();

var testAccount = ethAccounts.privateKeyToAccount(test.privateKey);
assert.equal(testAccount.address, test.address);

var tx = testAccount.signTransaction(test.transaction);
var tx = await testAccount.signTransaction(test.transaction);
assert.equal(ethAccounts.recoverTransaction(tx.rawTransaction), test.address);
});
});
Expand Down

0 comments on commit 440285e

Please sign in to comment.