Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cucumber): handles listHeaders response correctly #4551

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions integration_tests/features/support/node_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,18 @@ Then(
5 * height /* 5 seconds per block */
);
const currTip = await client.getTipHeader();
let currTipHeaderHeight = parseInt(currTip.header.height);
let currTipHeaderHeight = parseInt(currTip.height);
console.log(
`${name} is at tip ${currTipHeaderHeight} (${currTip.header.hash.toString(
`${name} is at tip ${currTipHeaderHeight} (${currTip.hash.toString(
"hex"
)})`
);
expect(currTipHeaderHeight).to.equal(height);
if (!tipHash) {
tipHash = currTip.header.hash.toString("hex");
tipHash = currTip.hash.toString("hex");
console.log(`Node ${name} is at tip: ${tipHash}`);
} else {
const currTipHash = currTip.header.hash.toString("hex");
const currTipHash = currTip.hash.toString("hex");
console.log(
`Node ${name} is at tip: ${currTipHash} (should be ${tipHash})`
);
Expand Down Expand Up @@ -506,7 +506,7 @@ Then(/node (.*) is at tip (.*)/, async function (node, name) {
const existingHeader = this.headers[name];
expect(existingHeader).to.not.be.null;
expect(existingHeader.header.hash.toString("hex")).to.equal(
header.header.hash.toString("hex")
header.hash.toString("hex")
);
});

Expand Down
26 changes: 10 additions & 16 deletions integration_tests/helpers/baseNodeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ class BaseNodeClient {
}

getHeaderAt(height) {
return this.client
.listHeaders()
.sendMessage({ from_height: height, num_headers: 1 })
.then((header) => {
console.log("Header:", header);
return header;
});
return this.getHeaders(height, 1).then((header) =>
header && header.length ? header[0].header : null
);
}

getNetworkDifficulties(tip, start, end) {
Expand All @@ -69,21 +65,19 @@ class BaseNodeClient {
}

getTipHeader() {
return this.client
.listHeaders()
.sendMessage({ from_height: 0, num_headers: 1 })
.then((headers) => {
const header = headers[0];
return Object.assign(header, {
height: +header.height,
});
return this.getHeaders(0, 1).then((headers) => {
const header = headers[0].header;
return Object.assign(header, {
height: +header.height,
});
});
}

async getHeaders(from_height, num_headers, sorting = 0) {
return await this.client
.listHeaders()
.sendMessage({ from_height, num_headers, sorting });
.sendMessage({ from_height, num_headers, sorting })
.then((resp) => resp.map((r) => r.header));
}

getTipHeight() {
Expand Down