Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add E2E tests for nonce formatting #3282

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion test/e2e.method.signing.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ describe('transaction and message signing [ @E2E ]', function() {
const networkId = await web3.eth.net.getId();
const chainId = await web3.eth.getChainId();


const customCommon = {
baseChain: 'mainnet',
customChain: {
Expand Down Expand Up @@ -113,6 +112,45 @@ describe('transaction and message signing [ @E2E ]', function() {
assert(receipt.status === true);
});

it('accounts.signTransaction, (nonce not specified)', async function(){
const source = wallet[0].address;
const destination = wallet[1].address;

const txObject = {
to: destination,
value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')),
gasLimit: web3.utils.toHex(21000),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
};

const signed = await web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey);
const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);

assert(receipt.status === true);
});

it('accounts.signTransaction, (nonce formatted as number)', async function(){
const source = wallet[0].address;
const destination = wallet[1].address;

const txCount = await web3.eth.getTransactionCount(source);

assert(typeof txCount === 'number');

const txObject = {
nonce: txCount,
to: destination,
value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')),
gasLimit: web3.utils.toHex(21000),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
};

const signed = await web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey);
const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);

assert(receipt.status === true);
});

it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(){
const source = wallet[0].address;
const destination = wallet[1].address;
Expand Down