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

tests: add test for options parsing #651

Merged
merged 8 commits into from
Jan 31, 2024
Merged

tests: add test for options parsing #651

merged 8 commits into from
Jan 31, 2024

Conversation

qiweiii
Copy link
Member

@qiweiii qiweiii commented Jan 29, 2024

closes: #604

@xlc
Copy link
Member

xlc commented Jan 29, 2024

I would like to test code in here as well

if (options.block == null) {
blockHash = await api.getBlockHash().then((hash) => {
if (!hash) {
// should not happen, but just in case
throw new Error('Cannot find block hash')
}
return hash
})
} else if (typeof options.block === 'string' && options.block.startsWith('0x')) {
blockHash = options.block as string
} else if (Number.isInteger(+options.block)) {
blockHash = await api.getBlockHash(Number(options.block)).then((hash) => {
if (!hash) {
throw new Error(`Cannot find block hash for ${options.block}`)
}
return hash
})
} else {
throw new Error(`Invalid block number or hash: ${options.block}`)
}

@qiweiii
Copy link
Member Author

qiweiii commented Jan 29, 2024

I would like to test code in here as well

if (options.block == null) {
blockHash = await api.getBlockHash().then((hash) => {
if (!hash) {
// should not happen, but just in case
throw new Error('Cannot find block hash')
}
return hash
})
} else if (typeof options.block === 'string' && options.block.startsWith('0x')) {
blockHash = options.block as string
} else if (Number.isInteger(+options.block)) {
blockHash = await api.getBlockHash(Number(options.block)).then((hash) => {
if (!hash) {
throw new Error(`Cannot find block hash for ${options.block}`)
}
return hash
})
} else {
throw new Error(`Invalid block number or hash: ${options.block}`)
}

agree, probably I shoud add an e2e test that read console output

@qiweiii qiweiii requested a review from xlc January 31, 2024 07:53
@xlc xlc merged commit 4a63bb4 into master Jan 31, 2024
6 checks passed
@xlc xlc deleted the tests/options-parsing branch January 31, 2024 08:21
@ermalkaleci
Copy link
Contributor

this is adding more tests which is good but doesn't actually tests the cli

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

Successfully merging this pull request may close these issues.

tests to ensure cli parsing code is correct
3 participants