Skip to content

Commit

Permalink
fix: commands for heimdall-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Dec 19, 2024
1 parent 2bcb9ce commit 3f85c2d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/integration-tests/smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ do
fi
fi

checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id)
checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .checkpoint.id)

if [ "$checkpointID" != "null" ]; then
if [ $checkpointFound != "true" ]; then
Expand Down
14 changes: 6 additions & 8 deletions src/express/commands/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ async function checkCheckpoint(ip) {
const url = `http://${ip}:1317/checkpoints/count`
const response = await fetch(url)
const responseJson = await response.json()
if (responseJson.result) {
if (responseJson.result.result) {
return responseJson.result.result
}
if (responseJson.ack_count) {
return responseJson.ack_count
}

return 0
Expand All @@ -74,8 +72,8 @@ async function checkStateSyncTx(ip, id) {
if (responseJson.error) {
return undefined
} else {
if (responseJson.result) {
return responseJson.result
if (responseJson.record) {
return responseJson.record
}
}

Expand All @@ -89,8 +87,8 @@ async function getStateSyncTxList(ip, startTime, endTime) {
if (responseJson.error) {
return undefined
} else {
if (responseJson.result) {
return responseJson.result
if (responseJson.record) {
return responseJson.record
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/express/commands/send-signer-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ async function getValidatorSigner(doc, machine0, validatorID) {
maxRetries
)
const outObj = JSON.parse(out)
return outObj.result.signer
return outObj.validator.signer
}
2 changes: 1 addition & 1 deletion src/express/commands/send-stake-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ async function getValidatorPower(doc, machine0, validatorID) {
maxRetries
)
const outObj = JSON.parse(out)
return outObj.result.power
return outObj.validator.voting_power
}
2 changes: 1 addition & 1 deletion src/express/commands/send-staked-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,5 @@ export async function checkValidatorsLength(doc, machine0) {
maxRetries
)
const outObj = JSON.parse(out)
return outObj.result.validators.length
return outObj.validator_set.validators.length
}
4 changes: 2 additions & 2 deletions src/express/commands/send-topupfee.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ export async function sendTopUpFeeEvent(validatorID) {
}

async function getValidatorBalance(doc, machine0, valAddr) {
const command = `curl http://localhost:1317/bank/balances/${valAddr}`
const command = `curl http://localhost:1317/cosmos/bank/v1beta1/balances/${valAddr}`
const out = await runSshCommandWithReturn(
`${doc.ethHostUser}@${machine0}`,
command,
maxRetries
)
const outObj = JSON.parse(out)
return outObj.result[0].amount
return outObj.balances[0].amount
}
8 changes: 4 additions & 4 deletions src/express/common/milestone-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,11 @@ export async function fetchLatestMilestone(
}

milestone = await checkLatestMilestone(host)
if (milestone.result) {
if (milestone.milestone) {
// Check against last milestone (if present) if it's immediate next one or not
if (lastMilestone) {
if (
Number(milestone.result.start_block) ===
Number(milestone.milestone.start_block) ===
Number(lastMilestone.end_block) + 1
) {
break
Expand All @@ -434,13 +434,13 @@ export async function fetchLatestMilestone(
} else {
console.log(
`📍Invalid milestone received. Response: ${JSON.stringify(
milestone.result
milestone.milestone
)}, count: ${count}`
)
}
}

const latestMilestone = milestone.result
const latestMilestone = milestone.milestone
console.log(
`📍Got milestone from heimdall. Start block: ${Number(
latestMilestone.start_block
Expand Down

0 comments on commit 3f85c2d

Please sign in to comment.