Skip to content

Commit

Permalink
Merge branch 'main' into feat/RA-60-Single-docker-container
Browse files Browse the repository at this point in the history
  • Loading branch information
MarMarMot committed Apr 25, 2024
2 parents 64c899d + af2a236 commit e34b7ca
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,33 @@ void getAccountBalanceInvalidAddressThrowTest() {
verifyNoMoreInteractions(accountIdentifier);
}

@Test
void getAccountBalanceWithStakeAddressAndNullBalanceThrowTest() {
String accountAddress =
ADDRESS_PREFIX + StakeAddressPrefix.TEST.getPrefix() + "1q9g8address_that_pass8";
PartialBlockIdentifier blockIdentifier = getMockedPartialBlockIdentifier();
AccountBalanceRequest accountBalanceRequest = Mockito.mock(AccountBalanceRequest.class);
AccountIdentifier accountIdentifier = getMockedAccountIdentifierAndMockAccountBalanceRequest(
accountBalanceRequest, blockIdentifier, accountAddress);
Block block = getMockBlock();
when(ledgerDataProviderService.findBlock(1L, HASH)).thenReturn(block);
when(ledgerDataProviderService.findStakeAddressBalanceByAddressAndBlock(accountAddress, 1L))
.thenReturn(null);

ApiException actualException = assertThrows(ApiException.class,
() -> accountService.getAccountBalance(accountBalanceRequest));

assertEquals(RosettaErrorType.INVALID_ADDRESS.getMessage(),
actualException.getError().getMessage());
verify(ledgerDataProviderService).findBlock(1L, HASH);
verify(ledgerDataProviderService).findStakeAddressBalanceByAddressAndBlock(accountAddress, 1L);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verifyNoMoreInteractions(ledgerDataProviderService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
}

@Test
void getAccountCoinsWithCurrenciesPositiveTest() {
String accountAddress = ADDRESS_PREFIX + "1q9g8address_that_pass8";
Expand Down
8 changes: 7 additions & 1 deletion postmanTests/Rosetta-java-env.postman_environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
"type": "default",
"enabled": true
},
{
"key": "TestAccountAddressWithUTXO",
"value": "addr_test1vzs0r2nae22szlq3ul3h8t4u7rz9dr850mqjh98caddm4zcypzjjt",
"type": "default",
"enabled": true
},
{
"key": "curveType",
"value": "edwards25519",
Expand Down Expand Up @@ -125,4 +131,4 @@
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-03-12T14:00:23.687Z",
"_postman_exported_using": "Postman/10.23.12"
}
}
8 changes: 7 additions & 1 deletion postmanTests/Rosetta-javaDevEnv.postman_environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
"type": "default",
"enabled": true
},
{
"key": "TestAccountAddressWithUTXO",
"value": "addr_test1vzs0r2nae22szlq3ul3h8t4u7rz9dr850mqjh98caddm4zcypzjjt",
"type": "default",
"enabled": true
},
{
"key": "curveType",
"value": "edwards25519",
Expand Down Expand Up @@ -117,4 +123,4 @@
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-03-21T09:44:37.390Z",
"_postman_exported_using": "Postman/10.24.6"
}
}
40 changes: 34 additions & 6 deletions postmanTests/rosetta-java.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,38 @@
" pm.response.to.have.status(200);",
"});",
"console.log(pm.response.json())",
"pm.test(\"Test account coins value\", function () {",
" var responseBody = pm.response.json();",
" pm.expect(responseBody).to.be.an('object');",
"});"
"pm.test(\"Body has not empty address\", function () {",
" const current_block_index = Number.parseInt(pm.environment.get('blockIndex'));",
" const current_block_hash = pm.environment.get('blockHash');",
" pm.expect(pm.response.json().block_identifier.index).to.not.eq(null)",
" pm.expect(pm.response.json().block_identifier.hash).to.not.eq(null)",
" pm.expect(pm.response.json().block_identifier.hash).to.not.eq(\"\")",
"});",
"",
"pm.test(\"Body has one or more UTxOs\", function () {",
" pm.expect(pm.response.json().coins.length).to.be.greaterThan(0)",
"});",
"",
"pm.test(\"UTxO has more than 1 ADA\", function () {",
" pm.expect(Number(pm.response.json().coins[0].amount.value)).to.be.greaterThan(1000000)",
"});",
"",
"const coin_with_metadata_index = pm.response.json().coins.findIndex(el => el.metadata != null);",
"const coin_identifier = pm.response.json().coins[coin_with_metadata_index].coin_identifier.identifier",
"",
"pm.test(\"UTxO has token policyId(s)\", function () {",
" pm.expect(pm.response.json().coins[coin_with_metadata_index].metadata[coin_identifier]).length.to.be.greaterThan(0)",
"});",
"",
"pm.test(\"Policy has 1 token\", function () {",
" pm.expect(pm.response.json().coins[coin_with_metadata_index].metadata[coin_identifier][0].tokens).to.have.lengthOf(1)",
"});",
"",
"pm.test(\"UTxO has Testcoin token(s)\", function () {",
" const value = Number(pm.response.json().coins[coin_with_metadata_index].metadata[coin_identifier][0].tokens[0].value)",
" pm.expect(value).to.be.greaterThan(0)",
"});",
""
],
"type": "text/javascript",
"packages": {}
Expand All @@ -902,7 +930,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"network_identifier\": {\n \"blockchain\": \"cardano\",\n \"network\": \"{{networkId}}\"\n },\n \"account_identifier\": {\n \"address\": \"{{TestAccountBaseAddress}}\"\n },\n \"include_mempool\": false\n}",
"raw": "{\n \"network_identifier\": {\n \"blockchain\": \"cardano\",\n \"network\": \"{{networkId}}\"\n },\n \"account_identifier\": {\n \"address\": \"{{TestAccountAddressWithUTXO}}\"\n },\n \"include_mempool\": false\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -988,4 +1016,4 @@
"value": ""
}
]
}
}

0 comments on commit e34b7ca

Please sign in to comment.