File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,23 @@ fn test_rest() -> Result<()> {
168
168
tester. mine ( ) ?;
169
169
assert_eq ! ( get_json( "/mempool" ) ?[ "count" ] . as_u64( ) , Some ( 0 ) ) ;
170
170
171
+ // Test POST /tx
172
+ let txid = tester. send ( & addr1, "9.9 BTC" . parse ( ) . unwrap ( ) ) ?;
173
+ let tx_hex = get_plain ( & format ! ( "/tx/{}/hex" , txid) ) ?;
174
+ // Re-send the tx created by send(). It'll be accepted again since its still in the mempool.
175
+ let broadcast1_resp = ureq:: post ( & format ! ( "http://{}/tx" , rest_addr) ) . send_string ( & tx_hex) ?;
176
+ assert_eq ! ( broadcast1_resp. status( ) , 200 ) ;
177
+ assert_eq ! ( broadcast1_resp. into_string( ) ?, txid. to_string( ) ) ;
178
+ // Mine the tx then submit it again. Should now fail.
179
+ tester. mine ( ) ?;
180
+ let broadcast2_res = ureq:: post ( & format ! ( "http://{}/tx" , rest_addr) ) . send_string ( & tx_hex) ;
181
+ let broadcast2_resp = broadcast2_res. unwrap_err ( ) . into_response ( ) . unwrap ( ) ;
182
+ assert_eq ! ( broadcast2_resp. status( ) , 400 ) ;
183
+ assert_eq ! (
184
+ broadcast2_resp. into_string( ) ?,
185
+ "sendrawtransaction RPC error -27: Transaction already in block chain"
186
+ ) ;
187
+
171
188
// Elements-only tests
172
189
#[ cfg( feature = "liquid" ) ]
173
190
{
You can’t perform that action at this time.
0 commit comments