Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
🌱 Add create transaction transfer without signature
Browse files Browse the repository at this point in the history
  • Loading branch information
tosch110 committed Jan 31, 2018
1 parent 5aaf562 commit 4d45f5f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
26 changes: 16 additions & 10 deletions src/commands/createTransactionTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,29 @@ export const actionCreator = vorpal => async ({ amount, address, options }) => {
const {
passphrase: passphraseSource,
'second-passphrase': secondPassphraseSource,
signature,
} = options;

validateAmount(amount);
validateAddress(address);

return getInputsFromSources(vorpal, {
passphrase: {
source: passphraseSource,
repeatPrompt: true,
},
secondPassphrase: !secondPassphraseSource
? null
: {
source: secondPassphraseSource,
return signature === false
? processInputs(amount, address)({
passphrase: null,
secondPassphrase: null,
})
: getInputsFromSources(vorpal, {
passphrase: {
source: passphraseSource,
repeatPrompt: true,
},
}).then(processInputs(amount, address));
secondPassphrase: !secondPassphraseSource
? null
: {
source: secondPassphraseSource,
repeatPrompt: true,
},
}).then(processInputs(amount, address));
};

const createTransactionTransfer = createCommand({
Expand Down
36 changes: 32 additions & 4 deletions test/specs/commands/createTransactionTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ describe('create transaction transfer command', () => {
() => {
Given('an action "create transaction transfer"', given.anAction, () => {
Given(
'a passphrase "minute omit local rare sword knee banner pair rib museum shadow juice"',
given.aPassphrase,
'a Lisk object that can create transactions',
given.aLiskObjectThatCanCreateTransactions,
() => {
Given(
'a Lisk object that can create transactions',
given.aLiskObjectThatCanCreateTransactions,
'a passphrase "minute omit local rare sword knee banner pair rib museum shadow juice"',
given.aPassphrase,
() => {
Given(
'an empty options object',
Expand Down Expand Up @@ -319,6 +319,34 @@ describe('create transaction transfer command', () => {
);
},
);
Given(
'an options object with signature set to "false"',
given.anOptionsObjectWithSignatureSetTo,
() => {
Given(
'an address "13356260975429434553L"',
given.anAddress,
() => {
Given('an amount "123"', given.anAmount, () => {
When(
'the action is called with the amount, the address and the options',
when.theActionIsCalledWithTheAmountTheAddressAndTheOptions,
() => {
Then(
'it should create a transfer transaction using the address and the amount',
then.itShouldCreateATransferTransactionUsingTheAddressAndTheAmount,
);
Then(
'it should resolve to the created transaction',
then.itShouldResolveToTheCreatedTransaction,
);
},
);
});
},
);
},
);
},
);
});
Expand Down
10 changes: 10 additions & 0 deletions test/steps/transactions/3_then.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ export function itShouldCreateACastVotesTransactionWithThePassphraseAndThePublic
});
}

export function itShouldCreateATransferTransactionUsingTheAddressAndTheAmount() {
const { address, amount } = this.test.ctx;
return transactions.transfer.should.be.calledWithExactly({
recipientId: address,
amount,
passphrase: null,
secondPassphrase: null,
});
}

export function itShouldCreateATransferTransactionUsingTheAddressTheAmountThePassphraseAndTheSecondPassphrase() {
const { passphrase, secondPassphrase, address, amount } = this.test.ctx;
return transactions.transfer.should.be.calledWithExactly({
Expand Down

0 comments on commit 4d45f5f

Please sign in to comment.