Skip to content

Commit

Permalink
implement cross sdk tests
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Jan 9, 2025
1 parent 2e0c748 commit a1aa79a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/heartbeat.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Address } from './encoding/address.js';
import { Encodable, Schema } from './encoding/encoding.js';
import {
AddressSchema,
Expand Down Expand Up @@ -113,7 +114,7 @@ export class Heartbeat implements Encodable {
])
);

public address: Uint8Array;
public address: Address;

public proof: HeartbeatProof;

Expand All @@ -124,7 +125,7 @@ export class Heartbeat implements Encodable {
public keyDilution: bigint;

public constructor(params: {
address: Uint8Array;
address: Address;
proof: HeartbeatProof;
seed: Uint8Array;
voteID: Uint8Array;
Expand Down
48 changes: 47 additions & 1 deletion tests/cucumber/steps/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,17 @@ module.exports = function getSteps(options) {
let anyBlockResponse;

When('we make any Get Block call', async function () {
anyBlockResponse = await doOrDoRaw(this.v2Client.block(1));
const req = this.v2Client.block(1);
if (responseFormat === 'json') {
// for json responses, we need to set the format query param and provide a custom decoder
// because the default block request only supports msgpack
req.query.format = responseFormat;
req.prepare = (response) => {
const body = new TextDecoder().decode(response.body);
return algosdk.decodeJSON(body, algosdk.modelsv2.BlockResponse);
};
}
anyBlockResponse = await doOrDoRaw(req);
});

Then(
Expand All @@ -2314,6 +2324,23 @@ module.exports = function getSteps(options) {
}
);

Then(
'the parsed Get Block response should have heartbeat address {string}',
(hbAddress) => {
// console.log(anyBlockResponse.block.payset[0].signedTxn.signedTxn.txn.heartbeat);
// console.log(anyBlockResponse.block.payset[0].signedTxn.signedTxn.txn.heartbeat.heartbeat.address);
// console.log(anyBlockResponse.block.payset[0].signedTxn.signedTxn.txn.heartbeat.heartbeat.proof);
// console.log(anyBlockResponse.block.payset[0].signedTxn.signedTxn.txn.heartbeat.heartbeat.seed);
assert.ok(
anyBlockResponse.block.payset[0].signedTxn.signedTxn.txn.heartbeat
.heartbeat.address instanceof algosdk.Address
);
const hbAddressString =
anyBlockResponse.block.payset[0].signedTxn.signedTxn.txn.heartbeat.heartbeat.address.toString();
assert.strictEqual(hbAddress, hbAddressString);
}
);

let anySuggestedTransactionsResponse;

When('we make any Suggested Transaction Parameters call', async function () {
Expand Down Expand Up @@ -3071,6 +3098,25 @@ module.exports = function getSteps(options) {
}
);

Then(
'the parsed SearchForTransactions response should be valid on round {int} and the array should be of len {int} and the element at index {int} should have hbaddress {string}',
(round, length, idx, hbAddress) => {
assert.strictEqual(
anySearchForTransactionsResponse.currentRound,
BigInt(round)
);
assert.strictEqual(
anySearchForTransactionsResponse.transactions.length,
length
);
assert.strictEqual(
anySearchForTransactionsResponse.transactions[idx].heartbeatTransaction
.hbAddress,
hbAddress
);
}
);

let anySearchForAssetsResponse;

When('we make any SearchForAssets call', async function () {
Expand Down
3 changes: 3 additions & 0 deletions tests/cucumber/unit.tags
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@unit.abijson.byname
@unit.algod
@unit.algod.ledger_refactoring
@unit.algod.heartbeat
@unit.algod.heartbeat.msgp
@unit.applications
@unit.applications.boxes
@unit.atomic_transaction_composer
Expand All @@ -13,6 +15,7 @@
@unit.indexer
@unit.indexer.ledger_refactoring
@unit.indexer.logs
@unit.indexer.heartbeat
@unit.offline
@unit.program_sanity_check
@unit.ready
Expand Down

0 comments on commit a1aa79a

Please sign in to comment.