-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
test(case): optimize test case #5456
test(case): optimize test case #5456
Conversation
1. add AccountAssetStoreTest 2. add AssetIssueStoreTest 3. add AssetIssueV2StoreTest 4. add ContractStoreTest
@Before | ||
public void init() { | ||
accountAssetStore.put(ASSET_KEY, Longs.toByteArray(200L)); | ||
|
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.
No need to add blank line
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.
This blank line does not affect the logic.
try { | ||
ownerCapsule.addAssetV2(ByteArray.fromString(String.valueOf(id)), TOTAL_SUPPLY); | ||
} catch (Exception e) { | ||
e.printStackTrace(); |
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 this be thrown?
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.
It is possible not to throw this exception
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.
Shall it be throw out but not be caught ?
long assetKey2 = createAsset("testToken2"); | ||
AccountCapsule accountCapsule = accountStore.get(ownerCapsule.getAddress().toByteArray()); | ||
|
||
Map<String, Long> allAssets = accountAssetStore.getAllAssets(accountCapsule.getInstance()); |
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.
Assert the assets count in the map?
assetIssueStore.put(assetIssueCapsule.createDbKey(), assetIssueCapsule); | ||
} | ||
|
||
private AssetIssueCapsule createAssetIssue(long id, String name) { |
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.
Is id param necessary?
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.
necessary, which is the ID in two different test cases
AssetIssueContractOuterClass.AssetIssueContract.newBuilder() | ||
.setName(ByteString.copyFrom(firstTokenId.getBytes())) | ||
.build()); | ||
assetIssueCapsule.setId(String.valueOf(2L)); |
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.
Will this id have conflict with other test cases?
|
||
@Test | ||
public void put() { | ||
String firstTokenId = "efg"; |
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.
why use this name "firstTokenId"?
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.
This has nothing to do with code logic
new ContractCapsule(contract.build())); | ||
} | ||
|
||
private SmartContractOuterClass.SmartContract.Builder createContract( |
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.
Why don't return a contractCapsule?
1. add DelegatedResourceStoreTest 2. add DelegationStoreTest 3. modify test case method name
What does this PR do?
add several test cases to cover more code verification scenarios
Why are these changes required?
to improve test case coverage
This PR has been tested by:
Follow up
Extra details