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

tokenUtxoDetails: fixed bug where UTXO array elems would switch #81

Merged
merged 4 commits into from
Dec 16, 2019

Conversation

christroutner
Copy link
Contributor

@christroutner christroutner commented Dec 16, 2019

This PR fixes a bug that Pete discovered in tokenUtxoDetails. The bug was triggered inconsistently. It was caused by the the elements in a UTXO array getting out-of-order compared to the validatedTxid array. The changes to code fix it by using the Array.filter method to make sure the right array element is being selected.

The changes in this PR effect only two files. The rest are compiler noise.

thisUtxo.vout !== 1 // UTXO is not the reciever of the genesis or mint tokens.
) {
// Can safely be marked as false.
outAry[i] = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the main changes in this PR. They center around more careful handling of the arrays and their elements.

}
}
}

return validations
return outAry
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the output variable name from validations to outAry. That's confusing git diff, and making it appear that I changed much more code than I actually did.

@@ -210,12 +210,12 @@ describe("#Utils", () => {
// Mock the call to rest.bitcoin.com
if (process.env.TEST === "unit") {
sandbox
.stub(axios, "get")
.stub(axios, "post")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this minor mocking bug while I was at it.

@@ -1059,5 +1059,106 @@ describe("#Utils", () => {
"tokenQty"
])
})

it("should process problematic utxos", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this new test case, based on the UTXOs that were causing the bug for Pete. This new test case will ensure we don't see this bug again.

Copy link

@SpicyPete SpicyPete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@christroutner christroutner merged commit 0de9b5c into master Dec 16, 2019
@christroutner christroutner deleted the ct-tokenUtxoDetails branch December 16, 2019 19:39
@cgcardona
Copy link
Contributor

🎉 This PR is included in version 4.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants