-
Notifications
You must be signed in to change notification settings - Fork 25
Integration tests: utxo-filter, utxo-consolidation, create-nft #164
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
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #164 +/- ##
=======================================
Coverage 85.78% 85.78%
=======================================
Files 19 19
Lines 647 647
Branches 132 132
=======================================
Hits 555 555
Misses 83 83
Partials 9 9 Continue to review full report at Codecov.
|
5d9ed6b
to
c6dd570
Compare
|
||
- name: Collect docker logs on failure | ||
if: failure() | ||
uses: jwalton/gh-docker-logs@v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this action to make an artifact with the logs on failure but isn't there any official action for this? Could we fork it as to not depend on this external action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a quick search I found no official action for this purpose.
The fact that this one is announced on the GitHub Action Marketplace gives me some confidence that this code will be running safely in the future, but I agree that a fork would be a safe solution as well.
Maybe we could open an issue dedicated to make this?
@@ -14,5 +14,5 @@ module.exports = { | |||
wsUpdateDelay: process.env.TEST_WS_UPDATE_DELAY || 1000, | |||
|
|||
// Defines for how long the startMultipleWalletsForTest can run | |||
walletStartTimeout: process.env.TEST_WALLET_START_TIMEOUT || 60000, | |||
walletStartTimeout: process.env.TEST_WALLET_START_TIMEOUT || 180000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is the default, but I think we should add this variable on the github config when running the CI.
This way we can change the value when we want (or for a batch of tests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable was added to GitHub on f8d62f2.
expect(nftErr).toBeInstanceOf(Error); | ||
expect(nftErr.response.text).toContain(field); | ||
} | ||
done(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just not use the done
when we don't need it.
it('should etc', async () => {
// test body
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests on the 3 suites within the scope of this PR were rewritten without the done()
call
expect(nftTx.hash).toBeDefined(); | ||
|
||
// Validating authority tokens | ||
const authorityOutputs = nftTx.outputs.filter(o => o.token_data === TOKEN_DATA.AUTHORITY_TOKEN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that TOKEN_DATA.AUTHORITY_TOKEN
is 129, which works because we only have 1 custom token on this tx but I don't think we should do it like this.
Instead, use the authority mask (128) and filter with the &
operator this will make sure this works even if we include multiple tokens on a transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! This would give a headache for a future test developer.
Fixed this on a1431c7
export const TOKEN_DATA = { | ||
HTR: 0, | ||
TOKEN: 1, | ||
AUTHORITY_TOKEN: 129 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use authority mask instead of assuming we only have 1 token on the tx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied the wallet-lib
constants mask on 7ada0f6
TestUtils.logError(errMsg); | ||
startBenchmark.failureAt = timestamp; | ||
startBenchmark.failureDiff = failureDiff; | ||
TestUtils.logTx(`Wallet init failure`, startBenchmark); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change logTx
to just log
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 765442b
jest-integration.config.js
Outdated
const mainTestMatch = process.env.SPECIFIC_INTEGRATION_TEST_FILE | ||
? `<rootDir>/__tests__/integration/**/${process.env.SPECIFIC_INTEGRATION_TEST_FILE}.test.js` | ||
: '<rootDir>/__tests__/integration/**/*.test.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sugestion: take this from command line arguments so we can run specific tests with npm run test_network_integration -- start
for instance
const mainTestMatch = process.env.SPECIFIC_INTEGRATION_TEST_FILE | |
? `<rootDir>/__tests__/integration/**/${process.env.SPECIFIC_INTEGRATION_TEST_FILE}.test.js` | |
: '<rootDir>/__tests__/integration/**/*.test.js' | |
const args = process.argv.slice(6); | |
const testMatch = args.length == 0 ? ['<rootDir>/__tests__/integration/**/*.test.js'] : args.map(arg => `<rootDir>/__tests__/integration/**/${arg}.test.js`); |
Obs: the slice(6)
is because we have "node", the filename and 4 other arguments we pass to jest on package.json
Edit: actually, we can already fillter tests with the command line wihtout this.
Running npm run test test_network_integration -- address
will match all tests on __tests__/integration/
but will filter with the pattern /address/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During my review I found it somewhat confusing when using helper methods to test the endpoints. |
A refactor was made to implement this on the three test suites that are in the scope of this PR. The test code is more straightforward now and doubles as documentation, as expected from tests. The only issue being that we have to remember to manually put pauses for websocket update where needed. |
# Conflicts: # __tests__/integration/txLogger.js # __tests__/integration/utils/test-utils-integration.js # __tests__/integration/utils/wallet-helper.js
# Conflicts: # .github/workflows/integration-test.yml
This pull request is the third phase of the implementation of Integration Tests on the Hathor Wallet Headless, and expands the scope of #149 and #152.
Acceptance Criteria
/wallet/utxo-filter
/wallet/utxo-consolidation
/wallet/create-nft
Other changes
Security Checklist