1515import org .xrpl .xrpl4j .model .client .fees .FeeUtils ;
1616import org .xrpl .xrpl4j .model .client .ledger .LedgerRequestParams ;
1717import org .xrpl .xrpl4j .model .client .transactions .SubmitResult ;
18+ import org .xrpl .xrpl4j .model .immutables .FluentCompareTo ;
19+ import org .xrpl .xrpl4j .model .transactions .Hash256 ;
1820import org .xrpl .xrpl4j .model .transactions .ImmutablePayment ;
1921import org .xrpl .xrpl4j .model .transactions .IssuedCurrencyAmount ;
2022import org .xrpl .xrpl4j .model .transactions .Payment ;
@@ -61,25 +63,30 @@ void setup() throws JsonRpcClientErrorException {
6163 }
6264
6365 @ Test
64- public void simpleIsFinalTest () throws JsonRpcClientErrorException , InterruptedException {
66+ public void simpleIsFinalTest () throws JsonRpcClientErrorException {
6567
6668 Payment builtPayment = payment .build ();
6769 SubmitResult response = xrplClient .submit (wallet , builtPayment );
6870 assertThat (response .result ()).isEqualTo ("tesSUCCESS" );
71+ Hash256 txHash = response .transactionResult ().hash ();
6972
7073 assertThat (
7174 xrplClient .isFinal (
72- response . transactionResult (). hash () ,
75+ txHash ,
7376 response .validatedLedgerIndex (),
7477 lastLedgerSequence ,
7578 accountInfo .accountData ().sequence (),
7679 wallet .classicAddress ()
7780 ).finalityStatus ()
7881 ).isEqualTo (FinalityStatus .NOT_FINAL );
79- Thread .sleep (4000 );
82+
83+ this .scanForResult (
84+ () -> getValidatedTransaction (txHash , Payment .class )
85+ );
86+
8087 assertThat (
8188 xrplClient .isFinal (
82- response . transactionResult (). hash () ,
89+ txHash ,
8390 response .validatedLedgerIndex (),
8491 lastLedgerSequence ,
8592 accountInfo .accountData ().sequence (),
@@ -89,27 +96,33 @@ public void simpleIsFinalTest() throws JsonRpcClientErrorException, InterruptedE
8996 }
9097
9198 @ Test
92- public void isFinalExpiredTxTest () throws JsonRpcClientErrorException , InterruptedException {
99+ public void isFinalExpiredTxTest () throws JsonRpcClientErrorException {
93100
94101 Payment builtPayment = payment
95102 .sequence (accountInfo .accountData ().sequence ().minus (UnsignedInteger .ONE ))
96103 .build ();
97104 SubmitResult response = xrplClient .submit (wallet , builtPayment );
105+ Hash256 txHash = response .transactionResult ().hash ();
98106
99107 assertThat (
100108 xrplClient .isFinal (
101- response . transactionResult (). hash () ,
109+ txHash ,
102110 response .validatedLedgerIndex (),
103111 lastLedgerSequence .minus (UnsignedInteger .ONE ),
104112 accountInfo .accountData ().sequence (),
105113 wallet .classicAddress ()
106114 ).finalityStatus ()
107115 ).isEqualTo (FinalityStatus .NOT_FINAL );
108- Thread .sleep (1000 );
116+
117+ this .scanForResult (
118+ () -> this .getValidatedLedger (),
119+ ledger -> FluentCompareTo .is (ledger .ledgerIndexSafe ().unsignedIntegerValue ())
120+ .greaterThan (lastLedgerSequence .minus (UnsignedInteger .ONE ))
121+ );
109122
110123 assertThat (
111124 xrplClient .isFinal (
112- response . transactionResult (). hash () ,
125+ txHash ,
113126 response .validatedLedgerIndex (),
114127 lastLedgerSequence .minus (UnsignedInteger .ONE ),
115128 accountInfo .accountData ().sequence (),
@@ -119,29 +132,32 @@ public void isFinalExpiredTxTest() throws JsonRpcClientErrorException, Interrupt
119132 }
120133
121134 @ Test
122- public void isFinalNoTrustlineIouPayment_ValidatedFailureResponse ()
123- throws JsonRpcClientErrorException , InterruptedException {
135+ public void isFinalNoTrustlineIouPayment_ValidatedFailureResponse () throws JsonRpcClientErrorException {
124136
125137 Payment builtPayment = payment
126138 .amount (IssuedCurrencyAmount .builder ().currency ("USD" ).issuer (
127139 wallet .classicAddress ()).value ("500" ).build ()
128140 ).build ();
129141 SubmitResult response = xrplClient .submit (wallet , builtPayment );
142+ Hash256 txHash = response .transactionResult ().hash ();
130143
131144 assertThat (
132145 xrplClient .isFinal (
133- response . transactionResult (). hash () ,
146+ txHash ,
134147 response .validatedLedgerIndex (),
135148 lastLedgerSequence ,
136149 accountInfo .accountData ().sequence (),
137150 wallet .classicAddress ()
138151 ).finalityStatus ()
139152 ).isEqualTo (FinalityStatus .NOT_FINAL );
140- Thread .sleep (1000 );
153+
154+ this .scanForResult (
155+ () -> getValidatedTransaction (txHash , Payment .class )
156+ );
141157
142158 assertThat (
143159 xrplClient .isFinal (
144- response . transactionResult (). hash () ,
160+ txHash ,
145161 response .validatedLedgerIndex (),
146162 lastLedgerSequence ,
147163 accountInfo .accountData ().sequence (),
0 commit comments