@@ -107,6 +107,74 @@ test('Valid TRANSFER transaction with multiple Ed25519 inputs', t => {
107
107
} )
108
108
109
109
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
+
110
178
test ( 'Search for spent and unspent outputs of a given public key' , t => {
111
179
const conn = new Connection ( API_PATH )
112
180
const carol = new Ed25519Keypair ( )
0 commit comments