Skip to content

Commit

Permalink
additional test case
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Nov 28, 2024
1 parent 9305007 commit c68aafe
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
40 changes: 40 additions & 0 deletions packages/api-http/integration/routes/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import receiptTransactions from "../../test/fixtures/receipt_transactions.json";
import transactions from "../../test/fixtures/transactions.json";
import transactionSchemas from "../../test/fixtures/transactions_schemas.json";
import transactionTypes from "../../test/fixtures/transactions_types.json";
import wallets from "../../test/fixtures/wallets.json";
import { ApiContext, prepareSandbox } from "../../test/helpers/prepare-sandbox";
import { request } from "../../test/helpers/request";

Expand Down Expand Up @@ -54,6 +55,12 @@ describe<{
.filter((tx) => tx.data === "")
.sort((a, b) => Number(b.blockHeight) - Number(a.blockHeight)),
},
{
path: "/transactions?data=",
result: [...transactions]
.filter((tx) => tx.data === "")
.sort((a, b) => Number(b.blockHeight) - Number(a.blockHeight)),
},
{ path: "/transactions?data=88888888", result: [] },
{
path: "/transactions?data=6dd7d8ea",
Expand All @@ -70,6 +77,39 @@ describe<{
}
});

it("/transactions?address", async () => {
await apiContext.transactionRepository.save(transactions);
await apiContext.walletRepository.save(wallets);

const transaction = transactions[transactions.length - 1];
const testCases = [
{
path: `/transactions?senderAddress=${transaction.senderAddress}`,
result: [...transactions]
.filter((tx) => tx.senderAddress === transaction.senderAddress)
.sort((a, b) => Number(b.blockHeight) - Number(a.blockHeight)),
},
{
path: `/transactions?senderId=${transaction.senderAddress}`,
result: [...transactions]
.filter((tx) => tx.senderAddress === transaction.senderAddress)
.sort((a, b) => Number(b.blockHeight) - Number(a.blockHeight)),
},
{
path: `/transactions?address=${transaction.recipientAddress}`,
result: [...transactions]
.filter((tx) => tx.recipientAddress === transaction.recipientAddress)
.sort((a, b) => Number(b.blockHeight) - Number(a.blockHeight)),
},
];

for (const { path, result } of testCases) {
const { statusCode, data } = await request(path, options);
assert.equal(statusCode, 200);
assert.equal(data.data, result);
}
});
//
it("/transactions/{id}", async () => {
await apiContext.transactionRepository.save(transactions);

Expand Down
6 changes: 3 additions & 3 deletions packages/api-http/test/fixtures/transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"sequence": 59,
"timestamp": "1728618018574",
"nonce": "0",
"senderPublicKey": "026ca1c7dee0077484706639523009189cbd58003fc96e5730cfa63fb1cc6b34e9",
"senderAddress": "0xB4e48Acd227b58B99425f482e55b9510BE40835B",
"senderPublicKey": "03f4cac5e34fe17ee0ba5a247d04350adfb67ffcabd74c29cca040e73788e7b2cb",
"senderAddress": "0xbCf7A45dBE4679E47dfDDca23f5cB1d6a4e73608",
"recipientAddress": "0x522B3294E6d06aA25Ad0f1B8891242E335D3B459",
"amount": "0",
"gasPrice": "0",
Expand All @@ -33,4 +33,4 @@
"signature": "7c21083caa26fd18dfeecfa75cd57a2e80836872db21608f6ebce1d772b98c9f31b6bb897118297f4c6138d19e7dedbaa1ed6c59816acb7410dc59fbaba54e1400",
"signatures": null
}
]
]
6 changes: 3 additions & 3 deletions packages/api-http/test/fixtures/wallets.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@
"updated_at": "0"
},
{
"address": "0x5C9b4723b238e30c8331573431EBd46bB9D48919",
"publicKey": "0291e54602a0d023b9289e560eea1c267b7769f6e3a40885ea5d450f7b59b0cef2",
"address": "0xdB1A9acDd71eb5F846059034EF6D2CB144cCd1A9",
"publicKey": "02b428a593af487a7ff7c755a5938ba527132fb850d9118252ec687d9a0b6ce8f7",
"balance": "2358490566037735849056603",
"nonce": "2",
"attributes": {
"vote": "0x5C9b4723b238e30c8331573431EBd46bB9D48919",
"vote": "0xdB1A9acDd71eb5F846059034EF6D2CB144cCd1A9",
"validatorRank": 20,
"validatorApproval": 0.0189,
"validatorResigned": false,
Expand Down

0 comments on commit c68aafe

Please sign in to comment.