Double spend test#7
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR simplifies predicate and token state handling by transitioning from specialized nametag token classes to generic token state implementations. The changes remove complexity around masked predicates and nametag-specific state while adding double spend prevention tests.
- Removes
NameTagTokenStateclass and its specialized constructor parameters - Replaces masked predicates with unmasked predicates throughout the codebase
- Adds comprehensive double spend test to verify transaction validation
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
TokenUtils.java |
Simplified nametag token minting by removing specialized parameters |
FunctionalUnsignedPredicateDoubleSpendTest.java |
New test file verifying double spend prevention |
CommonTestFlow.java |
Updated to use unmasked predicates and simplified token state creation |
NametagMintTransactionData.java |
Removed token data and coin data parameters from constructor |
Token.java |
Updated predicate verification to use transaction lists instead of single transactions |
NameTagTokenState.java |
Removed entire specialized token state class |
| Multiple predicate files | Updated verification methods to accept transaction lists |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public UnmaskedPredicate deserialize(JsonParser p, DeserializationContext ctx) | ||
| throws IOException { | ||
| PredicateType type = null; | ||
| PredicateType type; |
There was a problem hiding this comment.
The variable type is now uninitialized. This will cause a compilation error when used before assignment. Initialize to null or ensure it's assigned before use.
| PredicateType type; | |
| PredicateType type = null; |
| public MaskedPredicate deserialize(JsonParser p, DeserializationContext ctx) | ||
| throws IOException { | ||
| PredicateType type = null; | ||
| PredicateType type; |
There was a problem hiding this comment.
The variable type is now uninitialized. This will cause a compilation error when used before assignment. Initialize to null or ensure it's assigned before use.
| PredicateType type; |
| return super.verify(transactions, token) && SigningService.verifyWithPublicKey( | ||
| new DataHasher(HashAlgorithm.SHA256) | ||
| .update( | ||
| transactions.size() > 1 | ||
| ? transactions.get(transactions.size() - 2).getData().getSalt() | ||
| : token.getGenesis().getData().getSalt() | ||
| ) | ||
| .digest(), | ||
| this.getNonce(), | ||
| this.getPublicKey() | ||
| ); |
There was a problem hiding this comment.
When transactions.size() == 1, this accesses transactions.get(-1) which will throw an IndexOutOfBoundsException. The logic should check transactions.size() > 1 for the previous transaction access.
No description provided.