From e0391ee1bcebb418961957b1b19db7e343770de9 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 16 Jul 2018 00:20:36 -0400 Subject: [PATCH] Increased timeouts for some test cases that are failing in phantomjs on Travis CI. --- tests/test-contract-interface.js | 15 +++++++++++++++ tests/test-utils.js | 13 +++++++++++++ tests/test-wallet.js | 12 +++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/tests/test-contract-interface.js b/tests/test-contract-interface.js index b34a11d2e..92b468974 100644 --- a/tests/test-contract-interface.js +++ b/tests/test-contract-interface.js @@ -110,6 +110,7 @@ describe('ABI Coder Encoding', function() { var title = test.name + ' => (' + test.types + ') = (' + test.normalizedValues + ')'; it(('encodes paramters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); var encoded = coder.encode(types, values); assert.equal(encoded, result, 'encoded data - ' + title); }); @@ -128,6 +129,8 @@ describe('ABI Coder Decoding', function() { var title = test.name + ' => (' + test.types + ') = (' + test.normalizedValues + ')'; it(('decodes parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + var decoded = coder.decode(types, result); assert.ok(equals(decoded, values), 'decoded parameters - ' + title); @@ -147,6 +150,8 @@ describe('ABI Coder ABIv2 Encoding', function() { var title = test.name + ' => (' + test.types + ') = (' + test.value + ')'; it(('encodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + var encoded = coder.encode(types, values); assert.equal(encoded, expected, 'encoded positional parameters - ' + title); @@ -167,6 +172,8 @@ describe('ABI Coder ABIv2 Decoding', function() { var title = test.name + ' => (' + test.types + ') = (' + test.values + ')'; it(('decodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + var decoded = coder.decode(types, result); assert.ok(equals(decoded, values), 'decoded positional parameters - ' + title); }); @@ -178,6 +185,8 @@ describe('Test Contract Events', function() { var tests = utils.loadTests('contract-events'); tests.forEach(function(test, index) { it(('decodes event parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + var contract = new ethers.Interface(test.interface); var event = contract.events.testEvent; var parsed = event.decode(test.data, test.topics); @@ -194,6 +203,8 @@ describe('Test Contract Events', function() { tests.forEach(function(test, index) { it(('decodes event data - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + var contract = new ethers.Interface(test.interface); var event = contract.events.testEvent; var parsed = event.decode(test.data); @@ -217,6 +228,8 @@ describe('Test Interface Signatures', function() { tests.forEach(function(test) { var contract = new Interface(test.abi); it('derives the correct signature - ' + test.name, function() { + this.timeout(120000); + assert.equal(contract.functions.testSig.signature, test.signature, 'derived the correct signature'); assert.equal(contract.functions.testSig.sighash, test.sigHash, @@ -228,6 +241,8 @@ describe('Test Interface Signatures', function() { describe('Test Invalid Input', function() { var coder = ethers.utils.defaultAbiCoder; it('null input failed', function() { + this.timeout(120000); + assert.throws(function() { var result = coder.decode([ 'bool' ], '0x'); console.log(result); diff --git a/tests/test-utils.js b/tests/test-utils.js index 0c45534cb..d40e24c71 100644 --- a/tests/test-utils.js +++ b/tests/test-utils.js @@ -55,6 +55,7 @@ describe('Test Contract Address Generation', function() { Tests.forEach(function(test) { it(('Computes the transaction address - ' + test.name), function() { + this.timeout(120000); assert.equal(getContractAddress(test.tx), test.address, 'computes the transaction address'); }); }); @@ -67,12 +68,14 @@ describe('Test RLP Coder', function () { tests.forEach(function(test) { it(('RLP coder encoded - ' + test.name), function() { + this.timeout(120000); assert.equal(rlp.encode(test.decoded), test.encoded, 'RLP encoded - ' + test.name); }); }); tests.forEach(function(test) { it(('RLP coder decoded - ' + test.name), function() { + this.timeout(120000); assert.ok(equals(rlp.decode(test.encoded), test.decoded), 'RLP decoded - ' + test.name); }); @@ -109,6 +112,7 @@ describe('Test Unit Conversion', function () { if (test[name]) { it(('parses ' + test[name] + ' ' + name), function() { + this.timeout(120000); assert.ok(ethers.utils.parseUnits(test[name], unitName).eq(wei), ('parsing ' + name + ' failed - ' + test.name)); }); @@ -130,6 +134,7 @@ describe('Test Namehash', function() { var tests = utils.loadTests('namehash'); tests.forEach(function(test) { it(('computes namehash - "' + test.name + '"'), function() { + this.timeout(120000); assert.equal(ethers.utils.namehash(test.name), test.expected, 'computes namehash(' + test.name + ')'); }); @@ -147,6 +152,7 @@ describe('Test ID Hash Function', function () { tests.forEach(function(test) { it(('computes id - ' + test.name), function() { + this.timeout(120000); var value = ethers.utils.id(test.text); assert.equal(value, test.expected, 'computes id(' + test.text + ')'); @@ -158,6 +164,8 @@ describe('Test Solidity Hash Functions', function() { var tests = utils.loadTests('solidity-hashes'); ['Keccak256', 'Sha256'].forEach(function(funcName) { it(('computes ' + funcName + ' correctly'), function() { + this.timeout(120000); + tests.forEach(function(test, index) { var result = ethers.utils['solidity' + funcName](test.types, test.values); assert.equal(result, test[funcName.toLowerCase()], @@ -172,12 +180,14 @@ describe('Test Hash Functions', function() { var tests = utils.loadTests('hashes'); it('computes keccak256 correctly', function() { + this.timeout(120000); tests.forEach(function(test) { assert.equal(ethers.utils.keccak256(test.data), test.keccak256, ('Keccak256 - ' + test.data)); }); }); it('computes sha2566 correctly', function() { + this.timeout(120000); tests.forEach(function(test) { assert.equal(ethers.utils.sha256(test.data), test.sha256, ('SHA256 - ' + test.data)); }); @@ -187,6 +197,7 @@ describe('Test Hash Functions', function() { describe('Test Solidity splitSignature', function() { it('splits a canonical signature', function() { + this.timeout(120000); var r = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'; var s = '0xcafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7e'; for (var v = 27; v <= 28; v++) { @@ -199,6 +210,7 @@ describe('Test Solidity splitSignature', function() { }); it('splits a legacy signature', function() { + this.timeout(120000); var r = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'; var s = '0xcafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7e'; for (var v = 27; v <= 28; v++) { @@ -215,6 +227,7 @@ describe('Test Base64 coder', function() { // https://en.wikipedia.org/wiki/Base64#Examples it('encodes and decodes the example from wikipedia', function() { + this.timeout(120000); var decodedText = 'Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.'; var decoded = ethers.utils.toUtf8Bytes(decodedText); var encoded = 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4='; diff --git a/tests/test-wallet.js b/tests/test-wallet.js index 4563ae44a..bc4db5714 100644 --- a/tests/test-wallet.js +++ b/tests/test-wallet.js @@ -15,7 +15,7 @@ describe('Test JSON Wallets', function() { var tests = utils.loadTests('wallets'); tests.forEach(function(test) { it(('decrypts wallet - ' + test.name), function() { - this.timeout(1000000); + this.timeout(120000); assert.ok(Wallet.isEncryptedWallet(test.json), 'detect encrypted JSON wallet'); @@ -38,7 +38,7 @@ describe('Test JSON Wallets', function() { var password = 'foobar' + i; var wallet = new Wallet(utils.randomHexString('test-' + i, 32)); it('encrypts and decrypts a random wallet - ' + i, function() { - this.timeout(1000000); + this.timeout(120000); return wallet.encrypt(password).then(function(json) { return Wallet.fromEncryptedJson(json, password).then(function(decryptedWallet) { @@ -102,6 +102,8 @@ describe('Test Transaction Signing and Parsing', function() { var tests = utils.loadTests('transactions'); tests.forEach(function(test) { it(('parses and signs transaction - ' + test.name), function() { + this.timeout(120000); + var signingKey = new ethers.SigningKey(test.privateKey); var signDigest = signingKey.signDigest.bind(signingKey); @@ -213,7 +215,7 @@ describe('Test Signing Messages', function() { tests.forEach(function(test) { it(('signs a message "' + test.name + '"'), function() { - this.timeout(1000000); + this.timeout(120000); var wallet = new Wallet(test.privateKey); return wallet.signMessage(test.message).then(function(signature) { assert.equal(signature, test.signature, 'computes message signature'); @@ -223,7 +225,7 @@ describe('Test Signing Messages', function() { tests.forEach(function(test) { it(('verifies a message "' + test.name + '"'), function() { - this.timeout(1000000); + this.timeout(120000); var address = Wallet.verifyMessage(test.message, test.signature); assert.equal(address, test.address, 'verifies message signature'); }); @@ -231,7 +233,7 @@ describe('Test Signing Messages', function() { tests.forEach(function(test) { it(('hashes a message "' + test.name + '"'), function() { - this.timeout(1000000); + this.timeout(120000); var hash = ethers.utils.hashMessage(test.message); assert.equal(hash, test.messageHash, 'calculates message hash'); });