Skip to content

Commit 9f385c4

Browse files
manolodewinertim
manolodewiner
authored and
tim
committed
Add test of transaction with multiple inputs
1 parent e0f11ec commit 9f385c4

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

test/integration/test_integration.js

+68
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,74 @@ test('Valid TRANSFER transaction with multiple Ed25519 inputs', t => {
107107
})
108108

109109

110+
test('Valid TRANSFER transaction with multiple Ed25519 inputs from different transactions', t => {
111+
const conn = new Connection(API_PATH)
112+
const carol = new Ed25519Keypair()
113+
const carolCondition = Transaction.makeEd25519Condition(carol.publicKey)
114+
const carolOutput = Transaction.makeOutput(carolCondition)
115+
const trent = new Ed25519Keypair()
116+
const trentCondition = Transaction.makeEd25519Condition(trent.publicKey)
117+
const trentOutput = Transaction.makeOutput(trentCondition)
118+
const eli = new Ed25519Keypair()
119+
const eliCondition = Transaction.makeEd25519Condition(eli.publicKey)
120+
121+
const createTx = Transaction.makeCreateTransaction(
122+
asset(),
123+
metaData,
124+
[aliceOutput, bobOutput],
125+
alice.publicKey
126+
)
127+
const createTxSigned = Transaction.signTransaction(
128+
createTx,
129+
alice.privateKey
130+
)
131+
132+
return conn.postTransaction(createTxSigned)
133+
.then(({ 'id': txId }) => conn.pollStatusAndFetchTransaction(txId))
134+
.then(() => {
135+
const transferTx1 = Transaction.makeTransferTransaction(
136+
[{ tx: createTxSigned, output_index: 0 }],
137+
[carolOutput],
138+
metaData
139+
)
140+
const transferTxSigned1 = Transaction.signTransaction(
141+
transferTx1,
142+
alice.privateKey
143+
)
144+
const transferTx2 = Transaction.makeTransferTransaction(
145+
[{ tx: createTxSigned, output_index: 1 }],
146+
[trentOutput],
147+
metaData
148+
)
149+
const transferTxSigned2 = Transaction.signTransaction(
150+
transferTx2,
151+
bob.privateKey
152+
)
153+
154+
return conn.postTransaction(transferTxSigned1)
155+
.then(({ id }) => conn.pollStatusAndFetchTransaction(id))
156+
.then(conn.postTransaction(transferTxSigned2))
157+
.then(({ id }) => conn.pollStatusAndFetchTransaction(id))
158+
.then(() => {
159+
const transferTxMultipleInputs = Transaction.makeTransferTransaction(
160+
[{ tx: transferTxSigned1, output_index: 0 },
161+
{ tx: transferTxSigned2, output_index: 0 }],
162+
[Transaction.makeOutput(eliCondition, '2')],
163+
metaData
164+
)
165+
const transferTxSignedMultipleInputs = Transaction.signTransaction(
166+
transferTxMultipleInputs,
167+
carol.privateKey,
168+
trent.privateKey
169+
)
170+
return conn.postTransaction(transferTxSignedMultipleInputs)
171+
.then(({ id }) => conn.pollStatusAndFetchTransaction(id))
172+
.then(resTx => t.truthy(resTx))
173+
})
174+
})
175+
})
176+
177+
110178
test('Search for spent and unspent outputs of a given public key', t => {
111179
const conn = new Connection(API_PATH)
112180
const carol = new Ed25519Keypair()

0 commit comments

Comments
 (0)