Tests: no test covers a payment of 0 or the genesis block meeting the difficulty
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- blockchain, testing
Research direction
The two rules are in the README's "How it's supposed to work" section, and the code they describe is in Blockchain.java. Start by running mvn -B test and reading BlockchainTest, where blocksAreMinedAndLinked and startsWithGenesisBlock sit. Done means one new test file with a test that a zero-amount payment is rejected and a test that the genesis block's hash starts with the difficulty's zeros, and both fail when the mutations in the issue table are applied locally.
Written by the indexing model from the issue text.
Description
Two sentences in the README's "How it's supposed to work" section have no test that would fail if the code stopped following them.
Missing coverage
-
The amount has to be more than 0.
BlockchainTest.cannotMakeNegativePaymentonly tries-10. The boundary value0is never tried. The menu does reject it today ("Payment amount must be greater than zero."), but nothing would notice if it stopped. -
Every block's hash starts with as many zeros as the difficulty.
blocksAreMinedAndLinkedchecks the zeros in a loop that starts ati = 1, andstartsWithGenesisBlockonly checksgetPreviousHash(). The genesis block (block 0) is never checked.
Evidence
Checked on main @ 0e92205, JDK 17.0.12, Maven 3.9.16, by changing the code locally and running mvn -B test:
Local change to Blockchain.java |
Result |
|---|---|
tx.amount() <= 0 changed to tx.amount() < 0 (a 0 payment is accepted) |
all 18 tests still pass |
genesis.mine(difficulty); removed from the constructor (genesis is not mined) |
all 18 tests still pass |
Planned change
Add one new test file with one test for each rule. Tests only, no production code changes.
I'd like to work on this.
- Dominant language
- Java
- Stars
- 0
- Forks
- 3
- Avg merge
- 16h 38m
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from techcsispit/mini-chain
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads itPossibly taken @tanujb03 claimed this 2 days ago. Opendocumentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 25/100
techcsispit/mini-chain#21 ·
Maintainers usually reply within 1 day
-
BlockchainTest: signature tampering tests pass on the hash check; Block.mine() is a no-op so signature verification is not testedPossibly taken @tanujb03 claimed this 2 days ago. Opengood first issue tests
Difficulty 3/5 1-2 days Newbie friendliness 25/100
techcsispit/mini-chain#19 ·
Maintainers usually reply within 1 day
-
Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second timePossibly taken @tanujb03 claimed this 2 days ago. Openbug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 52/100
techcsispit/mini-chain#16 ·
Maintainers usually reply within 1 day
-
A signed payment can be altered (payee and amount) and still pass signature verificationPossibly taken @tanujb03 claimed this 2 days ago. Openadvanced bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
techcsispit/mini-chain#15 ·
Maintainers usually reply within 1 day
All issues in techcsispit/mini-chain
Similar issues
-
[BUG] Re-subscribing the Mono returned by listTools/listResources/listResourceTemplates/listPrompts/listRoots duplicates the resultsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelcontextprotocol/java-sdk#1174 · 1 reaction ·
Maintainers usually reply within 2 days
-
module: core
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
bigbluebutton/bigbluebutton#26028 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
MetricsHub/metricshub-community#1390 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/rocketmq-dashboard#6331 ·
Maintainers usually reply within 5 days
-
status: team-only type: dependency-upgrade
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
spring-projects/spring-boot#52143 · 1 comment ·
Maintainers usually reply within 1 day