Skip to content

Commit

Permalink
Add MeshAPI mempool/transaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
lrubasze committed Nov 11, 2024
1 parent c5d5b36 commit 066d14f
Showing 1 changed file with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@

import com.radixdlt.api.DeterministicMeshApiTestBase;
import com.radixdlt.api.core.generated.models.TransactionSubmitRequest;
import com.radixdlt.api.mesh.generated.models.NetworkIdentifier;
import com.radixdlt.api.mesh.generated.models.NetworkRequest;
import com.radixdlt.api.mesh.generated.models.TransactionIdentifier;
import com.radixdlt.api.mesh.generated.models.*;
import com.radixdlt.rev2.TransactionBuilder;
import java.util.List;
import org.apache.logging.log4j.LogManager;
Expand All @@ -85,15 +83,15 @@ public void test_mempool_queries() throws Exception {
try (var test = buildRunningServerTest(defaultConfig())) {
test.suppressUnusedWarning();

var transaction = TransactionBuilder.forTests().prepare();
var transaction1 = TransactionBuilder.forTests().prepare();

// Submit transaction to the CoreAPI
var response =
getCoreTransactionApi()
.transactionSubmitPost(
new TransactionSubmitRequest()
.network(networkLogicalName)
.notarizedTransactionHex(transaction.hexPayloadBytes()));
.notarizedTransactionHex(transaction1.hexPayloadBytes()));

assertThat(response.getDuplicate()).isFalse();

Expand All @@ -108,25 +106,38 @@ public void test_mempool_queries() throws Exception {
.notarizedTransactionHex(transaction2.hexPayloadBytes()));
assertThat(response.getDuplicate()).isFalse();

var network_identifier =
new NetworkIdentifier().blockchain("radix").network(networkLogicalName);
var transaction1_identifier =
new TransactionIdentifier().hash(addressing.encode(transaction1.transactionIntentHash()));
var transaction2_identifier =
new TransactionIdentifier().hash(addressing.encode(transaction2.transactionIntentHash()));

// Get mempool from the MeshAPI
var mempool_response =
getMempoolApi()
.mempool(
new NetworkRequest()
.networkIdentifier(
new NetworkIdentifier().blockchain("radix").network(networkLogicalName)))
.mempool(new NetworkRequest().networkIdentifier(network_identifier))
.getTransactionIdentifiers();

log.info("response = {}", mempool_response);

// Assert that both transactions are in the mempool list
// Assert that both transactions are in the mempool list
assertThat(
mempool_response.equals(List.of(transaction1_identifier, transaction2_identifier)));

var mempool_transaction_response =
getMempoolApi()
.mempoolTransaction(
new MempoolTransactionRequest()
.networkIdentifier(network_identifier)
.transactionIdentifier(transaction1_identifier))
.getTransaction();
log.info("response = {}", mempool_transaction_response);

// Assert that transaction1 is in the mempool transaction list
assertThat(
mempool_response.equals(
List.of(
new TransactionIdentifier()
.hash(addressing.encode(transaction2.transactionIntentHash())),
new TransactionIdentifier()
.hash(addressing.encode(transaction2.transactionIntentHash())))));
mempool_transaction_response.equals(
new Transaction().transactionIdentifier(transaction1_identifier)));
}
}
}

0 comments on commit 066d14f

Please sign in to comment.