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

feat(tokenFreezeTransaction): Implement TokenFreezeTransaction E2E tests: TCK #298

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
"arrowParens": "always",
"endOfLine": "lf"
}

36 changes: 18 additions & 18 deletions docs/test-specifications/token-service/tokenFreezeTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ The tests contained in this specification will assume that a valid account and a

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|-------------------|
| 1 | Freezes a token on an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze succeeds. | N |
| 2 | Freezes a token that doesn't exist on an account | tokenId="123.456.789", accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an INVALID_TOKEN_ID response code from the network. | N |
| 3 | Freezes a token with an empty token ID on an account | tokenId="", accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an SDK internal error. | N |
| 4 | Freezes a token with no token ID on an account | accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an INVALID_TOKEN_ID response code from the network. | N |
| 5 | Freezes a deleted token on an account | tokenId=<DELETED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<DELETED_TOKEN_FREEZE_KEY>] | The token freeze fails with an TOKEN_WAS_DELETED response code from the network. | N |
| 6 | Freezes a token on an account without signing with the token's freeze key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an INVALID_SIGNATURE response code from the network. | N |
| 7 | Freezes a token but signs with the token's admin key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_ADMIN_KEY>] | The token freeze fails with an INVALID_SIGNATURE response code from the network. | N |
| 8 | Freezes a token on an account but signs with an incorrect freeze key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<INCORRECT_VALID_PRIVATE_KEY>] | The token freeze fails with an INVALID_SIGNATURE response code from the network. | N |
| 9 | Freezes a token with no freeze key on an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an TOKEN_HAS_NO_FREEZE_KEY response code from the network. | N |
| 10 | Freezes a token that is already frozen on an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze succeeds. | N |
| 11 | Freezes a token on an account that is not associated with the token | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an TOKEN_NOT_ASSOCIATED_WITH_ACCOUNT response code from the network. | N |
| 12 | Freezes a paused token on an account | tokenId=<PAUSED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<PAUSED_TOKEN_FREEZE_KEY>] | The token freeze fails with an TOKEN_IS_PAUSED response code from the network. | N |
| 1 | Freezes a token on an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze succeeds. | Y |
| 2 | Freezes a token that doesn't exist on an account | tokenId="123.456.789", accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an INVALID_TOKEN_ID response code from the network. | Y |
| 3 | Freezes a token with an empty token ID on an account | tokenId="", accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an SDK internal error. | Y |
| 4 | Freezes a token with no token ID on an account | accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an INVALID_TOKEN_ID response code from the network. | Y |
| 5 | Freezes a deleted token on an account | tokenId=<DELETED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<DELETED_TOKEN_FREEZE_KEY>] | The token freeze fails with an TOKEN_WAS_DELETED response code from the network. | Y |
| 6 | Freezes a token on an account without signing with the token's freeze key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an INVALID_SIGNATURE response code from the network. | Y |
| 7 | Freezes a token but signs with the token's admin key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_ADMIN_KEY>] | The token freeze fails with an INVALID_SIGNATURE response code from the network. | Y |
| 8 | Freezes a token on an account but signs with an incorrect freeze key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<INCORRECT_VALID_PRIVATE_KEY>] | The token freeze fails with an INVALID_SIGNATURE response code from the network. | Y |
| 9 | Freezes a token with no freeze key on an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token freeze fails with an TOKEN_HAS_NO_FREEZE_KEY response code from the network. | Y |
| 10 | Freezes a token that is already frozen on an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze succeeds. | Y |
| 11 | Freezes a token on an account that is not associated with the token | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an TOKEN_NOT_ASSOCIATED_WITH_ACCOUNT response code from the network. | Y |
| 12 | Freezes a paused token on an account | tokenId=<PAUSED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<PAUSED_TOKEN_FREEZE_KEY>] | The token freeze fails with an TOKEN_IS_PAUSED response code from the network. | Y |

#### JSON Request Example

Expand Down Expand Up @@ -102,12 +102,12 @@ The tests contained in this specification will assume that a valid account and a

- The ID of the account to freeze.

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|-------------------|
| 1 | Freezes a token on an account that doesn't exist | tokenId=<CREATED_TOKEN_ID>, accountId="123.456.789", commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an INVALID_ACCOUNT_ID response code from the network. | N |
| 2 | Freezes a token on an account with an empty account ID | tokenId=<CREATED_TOKEN_ID>, accountId="", commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an SDK internal error. | N |
| 3 | Freezes a token on an account with no account ID | tokenId=<CREATED_TOKEN_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an INVALID_ACCOUNT_ID response code from the network. | N |
| 4 | Freezes a token on a deleted account | tokenId=<DELETED_TOKEN_ID>, accountId=<DELETED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an ACCOUNT_WAS_DELETED response code from the network. | N |
| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|-------------------|
| 1 | Freezes a token on an account that doesn't exist | tokenId=<CREATED_TOKEN_ID>, accountId="123.456.789", commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an INVALID_ACCOUNT_ID response code from the network. | Y |
| 2 | Freezes a token on an account with an empty account ID | tokenId=<CREATED_TOKEN_ID>, accountId="", commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an SDK internal error. | Y |
| 3 | Freezes a token on an account with no account ID | tokenId=<CREATED_TOKEN_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an INVALID_ACCOUNT_ID response code from the network. | Y |
| 4 | Freezes a token on a deleted account | tokenId=<DELETED_TOKEN_ID>, accountId=<DELETED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_FREEZE_KEY>] | The token freeze fails with an ACCOUNT_DELETED response code from the network. | Y |

#### JSON Request Example

Expand Down
10 changes: 8 additions & 2 deletions src/services/MirrorNodeClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fetchData } from "../utils/helpers/fetch-data";
import { retryOnError } from "../utils/helpers/retry-on-error";
import { fetchData } from "@helpers/fetch-data";
import { retryOnError } from "@helpers/retry-on-error";

class MirrorNodeClient {
private mirrorNodeRestUrl: string | undefined;
Expand All @@ -25,6 +25,12 @@ class MirrorNodeClient {
const url = `${this.mirrorNodeRestUrl}/api/v1/tokens/${tokenId}`;
return retryOnError(async () => fetchData(url));
}

// TODO: Get mirror node interface with OpenAPI
async getTokenRelationships(accountId: string): Promise<any> {
const url = `${this.mirrorNodeRestUrl}/api/v1/accounts/${accountId}/tokens`;
return retryOnError(async () => fetchData(url));
}
}

export default new MirrorNodeClient();
Loading