diff --git a/caver-conformance-tests/.circleci/config-sdk.yml b/caver-conformance-tests/.circleci/config-sdk.yml new file mode 100644 index 000000000..39508fdc2 --- /dev/null +++ b/caver-conformance-tests/.circleci/config-sdk.yml @@ -0,0 +1,189 @@ +version: 2.1 + +executors: + default: + docker: + - image: {{ project_image }} ## example: circleci/node:14.8 + working_directory: ~/{{ project_name }} + +commands: + notify-success: + steps: + - run: + name: "notify slack when job success" + command : | + curl --data '{"text": "✅ Job *'$CIRCLE_JOB'* succeeded on *'$CIRCLE_BRANCH''$CIRCLE_TAG'*. Please see '$CIRCLE_BUILD_URL' for details."}' "$SLACK_WEBHOOK_URL" + when: on_success + notify-failure: + steps: + - run: + name: "notify slack when job fail" + command : | + curl --data '{"text": "❌ Job *'$CIRCLE_JOB'* failed on *'$CIRCLE_BRANCH''$CIRCLE_TAG'*. Please see '$CIRCLE_BUILD_URL' for details."}' "$SLACK_WEBHOOK_URL" + when: on_fail + check_rc: + steps: + - run: + name: Check RC + command: | + if [[ -n $CIRCLE_TAG ]]; then + RC_NUMBER=${CIRCLE_TAG##*-} + # sed -i 's/^KLIP_SDK_VERSION_NAME.*/&-'${RC_NUMBER}'/' gradle.properties + # sed -n '/KLIP_SDK_VERSION_NAME/p' gradle.properties + else + echo "Not RC version" + fi +jobs: + unit_test: + executor: default + steps: + - checkout + - run: {{ test command }} + + lint_test: + executor: default + steps: + - checkout + - run: {{ test command }} + + integration_test: + executor: default + steps: + - checkout + - run: {{ test command }} + + build: + executor: default + steps: + - checkout + - check_rc + - run: {{ build command }} + - store_artifacts: ## If you want to store build_file + path: /tmp/artifacts ## Change path to build_file + + tag_verify: + executor: default + steps: + - checkout + - run: + name: "Verify tag and file verison match" + command: ./.circleci/scripts/tag_verify.sh ## Change script if version is not indicated on package.json + + publish: + executor: default + steps: + - checkout + ## This process only upload and flush cache on Cloudfront, if project deploy other way, need to add in this job + - check_rc + - run: + name: "Upload S3 bucket" + command: | + sudo apt-get install awscli + aws s3 sync ./ s3://$FRONTEND_BUCKET + - run: + name: "flush cache cloudfront" + command: | + aws configure set preview.cloudfront true + aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION --paths "/*" + - notify-failure + - notify-success + + release_PR: + executor: default + steps: + - add_ssh_keys + - checkout + - run: + name: "Push release branch" + command: | + set -x + echo "push to release branch: /release/${CIRCLE_TAG%-*}" + git checkout -b release/${CIRCLE_TAG%-*} + git push origin release/${CIRCLE_TAG%-*} + - run: + name: "Make PR to master branch" + command: ./.circleci/scripts/release_pr.sh + + tagging: + executor: default + steps: + - add_ssh_keys + - checkout + - run: + name: "Tagging and delete release branch" + command: ./.circleci/scripts/release_tag_branch.sh + +stage_defaults: + default: &stage_default + filters: + tags: + only: + - /^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*/ + - /^v[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+.*/ + branches: + ignore: + - /release\/.*/ + qa: &stage_qa + context: klip_sdk_prod + filters: + tags: + only: + - /^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*/ + - /^v[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+.*/ + branches: + ignore: /.*/ + rc: &stage_rc + context: klip_sdk_prod + filters: + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*/ + branches: + ignore: /.*/ + tests: &test_steps + requires: + - unit_test + - lint_test + - integration_test + - tag_verify + +workflows: + version: 2 + build_and_test: + jobs: + - unit_test: + <<: *stage_default + - lint_test: + <<: *stage_default + - integration_test: + <<: *stage_default + + # publish jobs - rc + - tag_verify: + <<: *stage_qa + filters: + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*/ + branches: + ignore: /.*/ + + - publish: + <<: *stage_qa + <<: *test_steps + name: publish_rc + + - release_PR: + <<: *stage_rc + requires: + - publish_rc + + # publish jobs - prod + - publish: + context: klip_sdk_prod + name: publish_prod + filters: + branches: + only: master + + - tagging: + requires: + - publish_prod diff --git a/caver-conformance-tests/.circleci/scripts/release_pr.sh b/caver-conformance-tests/.circleci/scripts/release_pr.sh new file mode 100755 index 000000000..9e6622a5c --- /dev/null +++ b/caver-conformance-tests/.circleci/scripts/release_pr.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -x + +curl -sSLf https://github.com/github/hub/releases/download/v2.12.3/hub-linux-amd64-2.12.3.tgz | \ + tar zxf - --strip-components=1 -C /tmp && \ + sudo mv /tmp/bin/hub /usr/local/bin/hub +type hub + +VERSION=$(hub pr list -s open -L 10 -f "%H%n") + +echo $VERSION +if [[ $VERSION == *"release/${CIRCLE_TAG%-*}"* ]]; then + echo "PR already exist" +else + echo "hub pull-request -m "[Master] release/$CIRCLE_TAG QA Signoff" -b $CIRCLE_PROJECT_USERNAME:master -h $CIRCLE_PROJECT_USERNAME:${CIRCLE_TAG%-*}" + echo -e "[Master] release/${CIRCLE_TAG%-*} QA Sign-off\n\nThis PR is automatically created by CI to release a new official version of $CIRCLE_PROJECT_REPONAME.\n\nWhen this PR is approved by QA team, a new version will be released." | hub pull-request -b $CIRCLE_PROJECT_USERNAME:master -h $CIRCLE_PROJECT_USERNAME:release/${CIRCLE_TAG%-*} -r $GITHUB_reviewer -l circleci -F- +fi diff --git a/caver-conformance-tests/.circleci/scripts/release_tag_branch.sh b/caver-conformance-tests/.circleci/scripts/release_tag_branch.sh new file mode 100755 index 000000000..c08e3b650 --- /dev/null +++ b/caver-conformance-tests/.circleci/scripts/release_tag_branch.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -x + +VERSION=v$(awk '/"version/ {gsub("\"",""); print $2}' package.json | tr -d ',') + +echo "Tagging major $VERSION" +git config --global user.email "team.devops@groundx.xyz" +git config --global user.name "circleci-gx" +git tag -a $VERSION -m "$CIRCLE_STAGE" +git push origin $VERSION + + +#delete release branch. it trigger by merge title +if [[ "release/v" = $(git log --oneline -1 | grep -o "release/v") ]]; then + echo "Delete branch release/$VERSION" + git push origin --delete release/$VERSION +else + echo "Need to delete branch manually" +fi diff --git a/caver-conformance-tests/.circleci/scripts/tag_verify.sh b/caver-conformance-tests/.circleci/scripts/tag_verify.sh new file mode 100755 index 000000000..e3c611e6a --- /dev/null +++ b/caver-conformance-tests/.circleci/scripts/tag_verify.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -x + +VERSION=v$(awk '/"version/ {gsub("\"",""); print $2}' package.json | tr -d ',') +echo "Pushing tag version is " $CIRCLE_TAG + +echo "version on version.go" $VERSION + +if [ $VERSION == ${CIRCLE_TAG%-*} ]; then + echo "Pushing tag and Real version match!" +else + echo "It's not same version." + exit 1 +fi diff --git a/caver-conformance-tests/.github/CODEOWNERS b/caver-conformance-tests/.github/CODEOWNERS new file mode 100644 index 000000000..9e59655bc --- /dev/null +++ b/caver-conformance-tests/.github/CODEOWNERS @@ -0,0 +1,24 @@ +# This is a comment. +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +#* @global-owner1 @global-owner2 + +# Order is important; the last matching pattern takes the most +# precedence. When someone opens a pull request that only +# modifies JS files, only @js-owner and not the global +# owner(s) will be requested for a review. +#*.js @js-owner + +# You can also use email addresses if you prefer. They'll be +# used to look up users just like we do for commit author +# emails. +#*.go docs@example.com + +# In this example, @doctocat owns any files in the build/logs +# directory at the root of the repository and any of its +# subdirectories. +#/build/logs/ @doctocat diff --git a/caver-conformance-tests/.gitignore b/caver-conformance-tests/.gitignore new file mode 100644 index 000000000..485dee64b --- /dev/null +++ b/caver-conformance-tests/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/caver-conformance-tests/README.md b/caver-conformance-tests/README.md new file mode 100644 index 000000000..5b031d562 --- /dev/null +++ b/caver-conformance-tests/README.md @@ -0,0 +1,92 @@ +# Caver Conformance Tests + +## Definition +> Conformance Test(이하 적합성 테스트)은 무엇인지 기술합니다. + +적합성 테스트란 "Klaytn SDK인 Caver가 구현된 언어에 상관 없이 표준을 따르고 있는가"를 테스트하는 것입니다. + +## Requirements +> 적합성 테스트를 위해 필요한 내용들을 기술합니다. + +* [KIP-34](https://kips.klaytn.com/KIPs/kip-34) 에 정의되어 있는 함수들은 적합성 테스트 범주에 들어갑니다. +* 세부적으로 테스트가 나뉘는 것들은 주된 사용성을 기준으로 테스트케이스를 설계하도록 합니다. + * e.g. `IKeyring.encrypt(password: String, options: Object): Object` 함수를 예로 들면, +options에 들어갈 수 있는 파라미터들이 여럿 있어 경우의 수가 많아지는데 이 때는 주된 사용성을 기준으로 옵션을 정하도록 합니다. +* Endpoint Node 또는 Klaytn Node 가 없이 테스트가 되어야 합니다. + * 실제 통신이 없이 Node로 전송하려는 Request Body가 적절히 인코딩되었는지 등을 확인하면 됩니다. +* Deprecated된 메서드, 함수는 Conformance Test 범주에 들어가지 않습니다. +r +## Conventions + +### 디렉토리 구조 및 파일명 +``` +. // caver-conformance-test-suite +// The directory tree of caver-conformance-test-suite +├── LayerInCommonArchitecture // Account, Wallet, and etc... +│ ├── ClassName1 // Classes(or structures) that make up the Layer +│ │ ├── methodName1.json +│ │ ├── ... +│ │ └── methodName2.json +│ ├── ... +│ └── ClassNameN +│ ├── ... +│ └── methodNameN.json +├── ... (Other layers) +└── Utils // Real example of Utils Layer: + └── Utils // Class Utils is a main component of Utils layer + ├── addHexPrefix.json + ├── checkAddressChecksum.json + ├── ... (Other methods in Utils class of Utils Layer) + └── stripHexPrefix.json +``` + +**Q & A** +* AbstractTransaction 클래스의 경우 테스트 케이스 정의는 어떻게 되나요? + * 실제 SDK를 사용하는 입장에서 생각해보면 각 트랜잭션 타입의 클래스별로 실행할 수 있게끔 존재하므로 해당 클래스 디렉토리에 `함수명.json`으로 정의하면 됩니다. + +### 테스트 케이스 파일 포맷 + +**예시: caver-conformance-tests/Utils/Utils/parseKlaytnWalletKey.json** +```json +{ + "parseKlaytnWalletKey": [ + { + "id": "CONFORMANCE-UTILS-01", + "description": "the given klaytn wallet key is a valid klaytn wallet key.", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": [ + "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "0x00", + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + ] + } + }, + { + "id": "CONFORMANCE-UTILS-02", + "description": "the given klaytn wallet key contains invalid private key.", + "input": { + "key": "0xzza915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid klaytn wallet key" + } + }, + { + "id": "CONFORMANCE-UTILS-03", + "description": "the given klaytn wallet key contains invalid type `0x03`.", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x030xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid klaytn wallet key" + } + } + ] +} +``` diff --git a/caver-conformance-tests/Utils/Utils/addHexPrefix.json b/caver-conformance-tests/Utils/Utils/addHexPrefix.json new file mode 100644 index 000000000..30c05c9ab --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/addHexPrefix.json @@ -0,0 +1,37 @@ +{ + "addHexPrefix": [ + { + "id": "CONFORMANCE-UTILS-055", + "description": "the given hexadecimal string already have prefix 0x, so 0x should not be added.", + "input": { + "str": "0x123" + }, + "expectedResult": { + "status": "pass", + "output": "0x123" + } + }, + { + "id": "CONFORMANCE-UTILS-056", + "description": "the given hexadecimal string already have prefix 0X, so 0x should not be added.", + "input": { + "str": "0X123" + }, + "expectedResult": { + "status": "pass", + "output": "0x123" + } + }, + { + "id": "CONFORMANCE-UTILS-057", + "description": "the given hexadecimal string have no prefix, so 0x should be added.", + "input": { + "str": "123" + }, + "expectedResult": { + "status": "pass", + "output": "0x123" + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/checkAddressChecksum.json b/caver-conformance-tests/Utils/Utils/checkAddressChecksum.json new file mode 100644 index 000000000..4a67a6aed --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/checkAddressChecksum.json @@ -0,0 +1,37 @@ +{ + "checkAddressChecksum": [ + { + "id": "CONFORMANCE-UTILS-008", + "description": "the given address has valid checksum.", + "input": { + "address": "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-009", + "description": "the given address has invalid checksum.", + "input": { + "address": "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d35D" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-010", + "description": "the given address is a zero address.", + "input": { + "address": "0x0000000000000000000000000000000000000000" + }, + "expectedResult": { + "status": "pass", + "output": true + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/compressPublicKey.json b/caver-conformance-tests/Utils/Utils/compressPublicKey.json new file mode 100644 index 000000000..f73d724e5 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/compressPublicKey.json @@ -0,0 +1,28 @@ +{ + "compressPublicKey": [ + { + "id": "CONFORMANCE-UTILS-031", + "description": "the given uncompressed public key without prefix is a valid public key.", + "input": { + "key": "0x77e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6ac8" + }, + "expectedResult": { + "status": "pass", + "output": "0x0277e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f357" + } + }, + { + "id": "CONFORMANCE-UTILS-032", + "description": "the given uncompressed public key has wrong prefix 09.", + "input": { + "key": "0x0977e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6ac8" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid public key", + "errorMessageJs": "Invalid public key", + "errorMessageJava": "Invalid public key." + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/convertFromPeb.json b/caver-conformance-tests/Utils/Utils/convertFromPeb.json new file mode 100644 index 000000000..1fb0274d7 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/convertFromPeb.json @@ -0,0 +1,345 @@ +{ + "convertFromPeb": [ + { + "id": "CONFORMANCE-UTILS-088", + "description": "convert from peb using TKLAY.", + "input": { + "num": "3000000000000000000000000000000", + "unit": "TKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-089", + "description": "convert from peb using GKLAY.", + "input": { + "num": "3000000000000000000000000000", + "unit": "GKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-090", + "description": "convert from peb using MKLAY.", + "input": { + "num": "3000000000000000000000000", + "unit": "MKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-091", + "description": "convert from peb using kKLAY.", + "input": { + "num": "3000000000000000000000", + "unit": "kKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-092", + "description": "convert from peb using KLAY.", + "input": { + "num": "3000000000000000000", + "unit": "KLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-093", + "description": "convert from peb using mKLAY.", + "input": { + "num": "3000000000000000", + "unit": "mKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-094", + "description": "convert from peb using uKLAY.", + "input": { + "num": "3000000000000", + "unit": "uKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-095", + "description": "convert from peb using ston.", + "input": { + "num": "3000000000", + "unit": "ston" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-096", + "description": "convert from peb using Gpeb.", + "input": { + "num": "3000000000", + "unit": "Gpeb" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-097", + "description": "convert from peb using Mpeb.", + "input": { + "num": "3000000", + "unit": "Mpeb" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-098", + "description": "convert from peb using kpeb.", + "input": { + "num": "3000", + "unit": "kpeb" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-099", + "description": "convert from peb using peb.", + "input": { + "num": "3", + "unit": "peb" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-100", + "description": "convert from peb using invalid unit.", + "input": { + "num": "3", + "unit": "cat" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "undefined klay unit", + "errorMessageJs": "This unit \"cat\" doesn't exist, please use the one of the following units{\n \"peb\": \"1\",\n \"kpeb\": \"1000\",\n \"Mpeb\": \"1000000\",\n \"Gpeb\": \"1000000000\",\n \"Ston\": \"1000000000\",\n \"ston\": \"1000000000\",\n \"uKLAY\": \"1000000000000\",\n \"mKLAY\": \"1000000000000000\",\n \"KLAY\": \"1000000000000000000\",\n \"kKLAY\": \"1000000000000000000000\",\n \"MKLAY\": \"1000000000000000000000000\",\n \"GKLAY\": \"1000000000000000000000000000\",\n \"TKLAY\": \"1000000000000000000000000000000\"\n}", + "errorMessageJava": "No enum constant com.klaytn.caver.utils.Utils.KlayUnit.cat" + } + }, + { + "id": "CONFORMANCE-UTILS-101", + "description": "convert from peb using TKLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000000000000000000000", + "klayUnit": { "unit": "TKLAY", "pebFactor": 30 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-102", + "description": "convert from peb using GKLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000000000000000000", + "klayUnit": { "unit": "GKLAY", "pebFactor": 27 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-103", + "description": "convert from peb using MKLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000000000000000", + "klayUnit": { "unit": "MKLAY", "pebFactor": 24 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-104", + "description": "convert from peb using kKLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000000000000", + "klayUnit": { "unit": "kKLAY", "pebFactor": 21 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-105", + "description": "convert from peb using KLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000000000", + "klayUnit": { "unit": "KLAY", "pebFactor": 18 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-106", + "description": "convert from peb using mKLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000000", + "klayUnit": { "unit": "mKLAY", "pebFactor": 15 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-107", + "description": "convert from peb using uKLAY with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000000", + "klayUnit": { "unit": "uKLAY", "pebFactor": 12 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-108", + "description": "convert from peb using ston with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000", + "klayUnit": { "unit": "ston", "pebFactor": 9 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-109", + "description": "convert from peb using Gpeb with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000000", + "klayUnit": { "unit": "Gpeb", "pebFactor": 9 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-110", + "description": "convert from peb using Mpeb with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000000", + "klayUnit": { "unit": "Mpeb", "pebFactor": 6 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-111", + "description": "convert from peb using kpeb with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3000", + "klayUnit": { "unit": "kpeb", "pebFactor": 3 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-112", + "description": "convert from peb using peb with KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "peb", "pebFactor": 0 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-113", + "description": "invalid KlayUnit.", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "cat", "pebFactor": 3 } + }, + "expectedResult": { + "status": "fail", + "errorMessage": "undefined klay unit", + "errorMessageJs": "This unit \"cat\" doesn't exist, please use the one of the following units{\n \"peb\": \"1\",\n \"kpeb\": \"1000\",\n \"Mpeb\": \"1000000\",\n \"Gpeb\": \"1000000000\",\n \"Ston\": \"1000000000\",\n \"ston\": \"1000000000\",\n \"uKLAY\": \"1000000000000\",\n \"mKLAY\": \"1000000000000000\",\n \"KLAY\": \"1000000000000000000\",\n \"kKLAY\": \"1000000000000000000000\",\n \"MKLAY\": \"1000000000000000000000000\",\n \"GKLAY\": \"1000000000000000000000000000\",\n \"TKLAY\": \"1000000000000000000000000000000\"\n}" + } + }, + { + "id": "CONFORMANCE-UTILS-114", + "description": "given peb factor does not match with given unit.", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "KLAY", "pebFactor": 3 } + }, + "expectedResult": { + "status": "fail", + "errorMessage": "peb factor does not match with given unit" + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/convertToPeb.json b/caver-conformance-tests/Utils/Utils/convertToPeb.json new file mode 100644 index 000000000..9bb370ff6 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/convertToPeb.json @@ -0,0 +1,345 @@ +{ + "convertToPeb": [ + { + "id": "CONFORMANCE-UTILS-061", + "description": "convert 3 peb to peb.", + "input": { + "num": "3", + "unit": "peb" + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-062", + "description": "convert 3 kpeb to peb.", + "input": { + "num": "3", + "unit": "kpeb" + }, + "expectedResult": { + "status": "pass", + "output": "3000" + } + }, + { + "id": "CONFORMANCE-UTILS-063", + "description": "convert 3 Mpeb to peb.", + "input": { + "num": "3", + "unit": "Mpeb" + }, + "expectedResult": { + "status": "pass", + "output": "3000000" + } + }, + { + "id": "CONFORMANCE-UTILS-064", + "description": "convert 3 Gpeb to peb.", + "input": { + "num": "3", + "unit": "Gpeb" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-065", + "description": "convert 3 ston to peb.", + "input": { + "num": "3", + "unit": "ston" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-066", + "description": "convert 3 uKLAY to peb.", + "input": { + "num": "3", + "unit": "uKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-067", + "description": "convert 3 mKLAY to peb.", + "input": { + "num": "3", + "unit": "mKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-068", + "description": "convert 3 KLAY to peb.", + "input": { + "num": "3", + "unit": "KLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-069", + "description": "convert 3 kKLAY to peb.", + "input": { + "num": "3", + "unit": "kKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-070", + "description": "convert 3 MKLAY to peb.", + "input": { + "num": "3", + "unit": "MKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-071", + "description": "convert 3 GKLAY to peb.", + "input": { + "num": "3", + "unit": "GKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-072", + "description": "convert 3 TKLAY to peb.", + "input": { + "num": "3", + "unit": "TKLAY" + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-073", + "description": "invalid unit.", + "input": { + "num": "3", + "unit": "cat" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "undefined klay unit", + "errorMessageJs": "This unit \"cat\" doesn't exist, please use the one of the following units{\n \"peb\": \"1\",\n \"kpeb\": \"1000\",\n \"Mpeb\": \"1000000\",\n \"Gpeb\": \"1000000000\",\n \"Ston\": \"1000000000\",\n \"ston\": \"1000000000\",\n \"uKLAY\": \"1000000000000\",\n \"mKLAY\": \"1000000000000000\",\n \"KLAY\": \"1000000000000000000\",\n \"kKLAY\": \"1000000000000000000000\",\n \"MKLAY\": \"1000000000000000000000000\",\n \"GKLAY\": \"1000000000000000000000000000\",\n \"TKLAY\": \"1000000000000000000000000000000\"\n}", + "errorMessageJava": "No enum constant com.klaytn.caver.utils.Utils.KlayUnit.cat" + } + }, + { + "id": "CONFORMANCE-UTILS-074", + "description": "convert 3 peb to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "peb", "pebFactor": 0 } + }, + "expectedResult": { + "status": "pass", + "output": "3" + } + }, + { + "id": "CONFORMANCE-UTILS-075", + "description": "convert 3 kpeb to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "kpeb", "pebFactor": 3 } + }, + "expectedResult": { + "status": "pass", + "output": "3000" + } + }, + { + "id": "CONFORMANCE-UTILS-076", + "description": "convert 3 Mpeb to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "Mpeb", "pebFactor": 6 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000" + } + }, + { + "id": "CONFORMANCE-UTILS-077", + "description": "convert 3 Gpeb to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "Gpeb", "pebFactor": 9 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-078", + "description": "convert 3 ston to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "ston", "pebFactor": 9 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-079", + "description": "convert 3 uKLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "uKLAY", "pebFactor": 12 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-080", + "description": "convert 3 mKLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "mKLAY", "pebFactor": 15 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-081", + "description": "convert 3 KLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "KLAY", "pebFactor": 18 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-082", + "description": "convert 3 kKLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "kKLAY", "pebFactor": 21 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-083", + "description": "convert 3 MKLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "MKLAY", "pebFactor": 24 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-084", + "description": "convert 3 GKLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "GKLAY", "pebFactor": 27 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-085", + "description": "convert 3 TKLAY to peb using KlayUnit(unit, pebFactor).", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "TKLAY", "pebFactor": 30 } + }, + "expectedResult": { + "status": "pass", + "output": "3000000000000000000000000000000" + } + }, + { + "id": "CONFORMANCE-UTILS-086", + "description": "invalid KlayUnit.", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "cat", "pebFactor": 3 } + }, + "expectedResult": { + "status": "fail", + "errorMessage": "undefined klay unit", + "errorMessageJs": "This unit \"cat\" doesn't exist, please use the one of the following units{\n \"peb\": \"1\",\n \"kpeb\": \"1000\",\n \"Mpeb\": \"1000000\",\n \"Gpeb\": \"1000000000\",\n \"Ston\": \"1000000000\",\n \"ston\": \"1000000000\",\n \"uKLAY\": \"1000000000000\",\n \"mKLAY\": \"1000000000000000\",\n \"KLAY\": \"1000000000000000000\",\n \"kKLAY\": \"1000000000000000000000\",\n \"MKLAY\": \"1000000000000000000000000\",\n \"GKLAY\": \"1000000000000000000000000000\",\n \"TKLAY\": \"1000000000000000000000000000000\"\n}" + } + }, + { + "id": "CONFORMANCE-UTILS-087", + "description": "given peb factor does not match with given unit.", + "skipJava": true, + "input": { + "num": "3", + "klayUnit": { "unit": "KLAY", "pebFactor": 3 } + }, + "expectedResult": { + "status": "fail", + "errorMessage": "peb factor does not match with given unit" + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/decodeSignature.json b/caver-conformance-tests/Utils/Utils/decodeSignature.json new file mode 100644 index 000000000..193336659 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/decodeSignature.json @@ -0,0 +1,47 @@ +{ + "decodeSignature": [ + { + "id": "CONFORMANCE-UTILS-123", + "description": "the valid raw signature should be decoded properly.", + "input": { + "rawSig": "0xc69018da9396c4b87947e0784625af7475caf46e2af9cf57a44673ff0f625258642d8993751ae67271bcc131aa065adccf9f16fc4953f9c48f4a80d675c09ae81b" + }, + "expectedResult": { + "status": "pass", + "output": { + "v": "1b", + "r": "c69018da9396c4b87947e0784625af7475caf46e2af9cf57a44673ff0f625258", + "s": "642d8993751ae67271bcc131aa065adccf9f16fc4953f9c48f4a80d675c09ae8" + } + } + }, + { + "id": "CONFORMANCE-UTILS-124", + "description": "the valid raw signature without hex prefix should be decoded properly.", + "input": { + "rawSig": "4c78ba080e717534772c4a9714b06a12f8d41062fca72885dafa8f1e1d6d78de35a50522df6361d16c05d1368bb9d86da1054f153301d5dedc6658d222616edd1b" + }, + "expectedResult": { + "status": "pass", + "output": { + "v": "1b", + "r": "4c78ba080e717534772c4a9714b06a12f8d41062fca72885dafa8f1e1d6d78de", + "s": "35a50522df6361d16c05d1368bb9d86da1054f153301d5dedc6658d222616edd" + } + } + }, + { + "id": "CONFORMANCE-UTILS-125", + "description": "given raw signature is invalid. The length of raw signature must be 65 byte.", + "input": { + "rawSig": "0xabcdef" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid signature", + "errorMessageJs": "Invalid signature: The length of raw signature must be 65 byte.", + "errorMessageJava": "Invalid signature: The length of raw signature must be 65 byte." + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/decompressPublicKey.json b/caver-conformance-tests/Utils/Utils/decompressPublicKey.json new file mode 100644 index 000000000..2c5e6d119 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/decompressPublicKey.json @@ -0,0 +1,29 @@ +{ + "decompressPublicKey": [ + { + "id": "CONFORMANCE-UTILS-033", + "description": "the given compressed public key is a valid public key starts with prefix 02", + "input": { + "key": "0x0277e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f357" + }, + "expectedResult": { + "status": "pass", + "output": "0x77e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6ac8" + } + }, + { + "id": "CONFORMANCE-UTILS-034", + "description": "the given compressed public key starts with wrong prefix 11", + "input": { + "key": "0x1177e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f357" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid public key", + "errorMessageJs": "Invalid public key", + "errorMessageJava": "Invalid public key." + + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/hashMessage.json b/caver-conformance-tests/Utils/Utils/hashMessage.json new file mode 100644 index 000000000..f4630c201 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/hashMessage.json @@ -0,0 +1,26 @@ +{ + "hashMessage": [ + { + "id": "CONFORMANCE-UTILS-038", + "description": "hash string.", + "input": { + "message": "Hello World" + }, + "expectedResult": { + "status": "pass", + "output": "0xf334bf277b674260e85f1a3d2565d76463d63d29549ef4fa6d6833207576b5ba" + } + }, + { + "id": "CONFORMANCE-UTILS-039", + "description": "hash hex string", + "input": { + "message": "0x48656c6c6f20576f726c64" + }, + "expectedResult": { + "status": "pass", + "output": "0xf334bf277b674260e85f1a3d2565d76463d63d29549ef4fa6d6833207576b5ba" + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/isAddress.json b/caver-conformance-tests/Utils/Utils/isAddress.json new file mode 100644 index 000000000..e4c56842f --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isAddress.json @@ -0,0 +1,81 @@ +{ + "isAddress": [ + { + "id": "CONFORMANCE-UTILS-001", + "description": "the given address is a valid Klaytn account address.", + "input": { + "address": "0x95722fcdc800275dE673AcD02f09aDE8973AE12D" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-002", + "description": "the given small letter address is a valid Klaytn account address.", + "input": { + "address": "0xff6916ea19a50878e39c41aaadfeb0cab1b41dad" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-003", + "description": "the given capital letter address is a valid Klaytn account address.", + "input": { + "address": "0xFF6916EA19A50878E39C41AAADFEB0CAB1B41DAD" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-004", + "description": "the given address is a zero address.", + "input": { + "address": "0x0000000000000000000000000000000000000000" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-005", + "description": "the given address is a shorten zero address.", + "input": { + "address": "0x0" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-006", + "description": "the given address is not valid. It's not hex string.", + "input": { + "address": "0xKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-007", + "description": "the given address has invalid checksum.", + "input": { + "address": "0x2058a550ea824841e991ef386c3aD63D088303B3" + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/isEmptySig.json b/caver-conformance-tests/Utils/Utils/isEmptySig.json new file mode 100644 index 000000000..bf466a458 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isEmptySig.json @@ -0,0 +1,78 @@ +{ + "isEmptySig": [ + { + "id": "CONFORMANCE-UTILS-119", + "description": "the given signature is empty.", + "input": { + "signature": { + "v": "0x01", + "r": "0x", + "s": "0x" + } + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-120", + "description": "the given signature is not empty.", + "input": { + "signature": { + "v": "0x25", + "r": "0xb2a5a15550ec298dc7dddde3774429ed75f864c82caeb5ee24399649ad731be9", + "s": "0x29da1014d16f2011b3307f7bbe1035b6e699a4204fc416c763def6cefd976567" + } + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-121", + "description": "the given signatures are all empty.", + "input": { + "signatures": [ + { + "v": "0x01", + "r": "0x", + "s": "0x" + }, + { + "v": "0x01", + "r": "0x", + "s": "0x" + } + ] + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-122", + "description": "the given signatures are partially empty.", + "input": { + "signatures": [ + { + "v": "0x25", + "r": "0xb2a5a15550ec298dc7dddde3774429ed75f864c82caeb5ee24399649ad731be9", + "s": "0x29da1014d16f2011b3307f7bbe1035b6e699a4204fc416c763def6cefd976567" + }, + { + "v": "0x01", + "r": "0x", + "s": "0x" + } + ] + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/isHex.json b/caver-conformance-tests/Utils/Utils/isHex.json new file mode 100644 index 000000000..45782dc28 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isHex.json @@ -0,0 +1,70 @@ +{ + "isHex": [ + { + "id": "CONFORMANCE-UTILS-043", + "description": "the given string is a hexadecimal number (even bytes).", + "input": { + "str": "0x1234" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-044", + "description": "the given string is a hexadecimal number (odd bytes).", + "input": { + "str": "0x12" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-045", + "description": "the given string is a hexadecimal number with prefix 0X.", + "input": { + "str": "0x12f" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-046", + "description": "the given string is a hexadecimal number (no preceding 0x, even bytes).", + "input": { + "str": "1234" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-047", + "description": "the given string is a hexadecimal number (no preceding 0x, odd bytes).", + "input": { + "str": "0x12f" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-048", + "description": "the given string is not a hexadecimal.", + "input": { + "str": "0xsomething" + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/isHexStrict.json b/caver-conformance-tests/Utils/Utils/isHexStrict.json new file mode 100644 index 000000000..62ca49497 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isHexStrict.json @@ -0,0 +1,70 @@ +{ + "isHexStrict": [ + { + "id": "CONFORMANCE-UTILS-049", + "description": "the given string is a hexadecimal number (even bytes).", + "input": { + "str": "0x1234" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-050", + "description": "the given string is a hexadecimal number (odd bytes).", + "input": { + "str": "0x12" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-051", + "description": "the given string is a hexadecimal number with prefix 0X.", + "input": { + "str": "0x12f" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-052", + "description": "the given string has no preceding 0x (even bytes).", + "input": { + "str": "1234" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-053", + "description": "the given string has no preceding 0x (odd bytes).", + "input": { + "str": "12f" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-054", + "description": "the given string is not a hexadecimal.", + "input": { + "str": "0xsomething" + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/isKlaytnWalletKey.json b/caver-conformance-tests/Utils/Utils/isKlaytnWalletKey.json new file mode 100644 index 000000000..6829c1755 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isKlaytnWalletKey.json @@ -0,0 +1,103 @@ +{ + "isKlaytnWalletKey": [ + { + "id": "CONFORMANCE-UTILS-014", + "description": "the given klaytn wallet key is a valid klaytn wallet key.", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-015", + "description": "the given klaytn wallet key contains invalid private key.", + "input": { + "key": "0xzza915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-016", + "description": "the given klaytn wallet key contains invalid type `0x03`.", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x030xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-017", + "description": "the given klaytn wallet key contains invalid address.", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebfzz" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-018", + "description": "the given klaytn wallet key is missing preceding 0x.", + "input": { + "key": "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d800a94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-019", + "description": "the given klaytn wallet key has duplicated prefix 0x of the private key.", + "input": { + "key": "0x0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-020", + "description": "the given klaytn wallet key has invalid type length 0x0000(2 bytes).", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x0000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-021", + "description": "the given klaytn wallet key has invalid address (which is 1 byte short address).", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-022", + "description": "the given klaytn wallet key contains invalid private key.", + "input": { + "key": "0x00000000000000000000000000000000000000000000000000000000000000000x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/isValidPrivateKey.json b/caver-conformance-tests/Utils/Utils/isValidPrivateKey.json new file mode 100644 index 000000000..79fa9b0a9 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isValidPrivateKey.json @@ -0,0 +1,37 @@ +{ + "isValidPrivateKey": [ + { + "id": "CONFORMANCE-UTILS-011", + "description": "the given private key is a valid private key.", + "input": { + "key": "0xd0c8ae2a70809c0df5c54670a6d7e938210875559bc0af462e0f9c50adf452b6" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-012", + "description": "the given private key is 1 byte short.", + "input": { + "key": "0xd0c8ae2a70809c0df5c54670a6d7e938210875559bc0af462e0f9c50adf452" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-013", + "description": "the given private key is not a hex string.", + "input": { + "key": "0xff6916ea19a50878e39c41cab1b41d0xff6916ea19a50878e39c41cab1bdd4KK" + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/isValidPublicKey.json b/caver-conformance-tests/Utils/Utils/isValidPublicKey.json new file mode 100644 index 000000000..b0712c203 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/isValidPublicKey.json @@ -0,0 +1,92 @@ +{ + "isValidPublicKey": [ + { + "id": "CONFORMANCE-UTILS-023", + "description": "the given raw public key is a valid public key.", + "input": { + "key": "0x1e7bcc70c72770dbb72fea022e8a6d07f814d2ebe4de9ae3f7af75bf706902a7b73ff919898c836396a6b0c96812c3213b99372050853bd1678da0ead14487d7" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-024", + "description": "the given raw public key is a valid public key (x starts with 0).", + "input": { + "key": "0x0b88d831c595f59b7fa50bebddd11d10c77017c3aeca47056e79b143383bd2a2db1dfff0728df2ee5c742729644831f2d39c6781ee32b98b13b708d0ca349c2a" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-025", + "description": "the given raw public key is a valid public key (y starts with 0).", + "input": { + "key": "0x77e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6ac8" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-026", + "description": "the given uncompressed public key is a valid public key (starts with 04).", + "input": { + "key": "0x04019b186993b620455077b6bc37bf61666725d8d87ab33eb113ac0414cd48d78ff46e5ea48c6f22e8f19a77e5dbba9d209df60cbcb841b7e3e81fe444ba829831" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-027", + "description": "the given compressed public key is a valid public key (starts with 02.", + "input": { + "key": "0x0277e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f357" + }, + "expectedResult": { + "status": "pass", + "output": true + } + }, + { + "id": "CONFORMANCE-UTILS-028", + "description": "the given raw public key is 1-byte short.", + "input": { + "key": "0x1e7bcc70c72770dbb72fea022e8a6d07f814d2ebe4de9ae3f7af75bf706902a7b73ff919898c836396a6b0c96812c3213b99372050853bd1678da0ead14487" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-029", + "description": "the given compressed public key starts with wrong prefix 09.", + "input": { + "key": "0x0977e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f357" + }, + "expectedResult": { + "status": "pass", + "output": false + } + }, + { + "id": "CONFORMANCE-UTILS-030", + "description": "the given uncompressed public key is not on a curve.", + "input": { + "key": "0x4be11ff42d8fc1954fb9ed52296db1657564c5e38517764664fb7cf4306a1e163a2686aa755dd0291aa2f291c3560ef4bf4b46c671983ff3e23f11a1b744ff4a" + }, + "expectedResult": { + "status": "pass", + "output": false + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/parseKlaytnWalletKey.json b/caver-conformance-tests/Utils/Utils/parseKlaytnWalletKey.json new file mode 100644 index 000000000..333527542 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/parseKlaytnWalletKey.json @@ -0,0 +1,45 @@ +{ + "parseKlaytnWalletKey": [ + { + "id": "CONFORMANCE-UTILS-040", + "description": "the given klaytn wallet key is a valid klaytn wallet key.", + "input": { + "key": "0x8dae976590384fe06ae40cc5e2f79d5f2726a4733627d8fcb664c193c46985bf0x000xf2f0566906bc0f19bbc97914ec36762cdf312f80" + }, + "expectedResult": { + "status": "pass", + "output": [ + "0x8dae976590384fe06ae40cc5e2f79d5f2726a4733627d8fcb664c193c46985bf", + "0x00", + "0xf2f0566906bc0f19bbc97914ec36762cdf312f80" + ] + } + }, + { + "id": "CONFORMANCE-UTILS-041", + "description": "the given klaytn wallet key contains invalid private key.", + "input": { + "key": "0xzza915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid klaytn wallet key", + "errorMessageJs": "Invalid KlaytnWalletKey format: 0xzza915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x000xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "errorMessageJava": "Invalid Klaytn wallet key." + } + }, + { + "id": "CONFORMANCE-UTILS-042", + "description": "the given klaytn wallet key contains invalid type `0x03`.", + "input": { + "key": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x030xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid klaytn wallet key", + "errorMessageJs": "Invalid KlaytnWalletKey format: 0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d80x030xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "errorMessageJava": "Invalid Klaytn wallet key." + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/publicKeyToAddress.json b/caver-conformance-tests/Utils/Utils/publicKeyToAddress.json new file mode 100644 index 000000000..5788507fa --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/publicKeyToAddress.json @@ -0,0 +1,39 @@ +{ + "publicKeyToAddress": [ + { + "id": "CONFORMANCE-UTILS-035", + "description": "the given raw public key is a valid public key.", + "input": { + "key": "0x77e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6ac8" + }, + "expectedResult": { + "status": "pass", + "output": "0x7F1cdc74051cf788998bBf6caD35E29722fd2925" + } + }, + { + "id": "CONFORMANCE-UTILS-036", + "description": "the given compressed public key is a valid public key.", + "input": { + "key": "0x02dbac81e8486d68eac4e6ef9db617f7fbd79a04a3b323c982a09cdfc61f0ae0e8" + }, + "expectedResult": { + "status": "pass", + "output": "0x90B3E9A3770481345A7F17f22f16D020Bccfd33e" + } + }, + { + "id": "CONFORMANCE-UTILS-037", + "description": "the given raw public key is 1 byte short.", + "input": { + "key": "0x77e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6a" + }, + "expectedResult": { + "status": "fail", + "errorMessage": "invalid public key", + "errorMessageJs": "Invalid public key: 0x77e05dd93cdd6362f8648447f33d5676cbc5f42f4c4946ae1ad62bd4c0c4f3570b1a104b67d1cd169bbf61dd557f15ab5ee8b661326096954caddadf34ae6a", + "errorMessageJava": "Invalid public key." + } + } + ] +} diff --git a/caver-conformance-tests/Utils/Utils/recover.json b/caver-conformance-tests/Utils/Utils/recover.json new file mode 100644 index 000000000..11a6a5e26 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/recover.json @@ -0,0 +1,37 @@ +{ + "recover": [ + { + "id": "CONFORMANCE-UTILS-115", + "description": "recover address which was used to sign message.", + "input": { + "message": "Some data", + "signature": { + "v": "0x1b", + "r": "0xb52c2b9711285c85676f98361540c780dc14d8a606fc554b8f074b153d5050c9", + "s": "0x158925d3b999a6463917b587869b3cd64f24efc948e6eceec71aadcfe2a52129" + } + }, + "expectedResult": { + "status": "pass", + "output": "0xF8b7150Ef854b860d39F1B4b837540eb09B9E9e5" + } + }, + { + "id": "CONFORMANCE-UTILS-116", + "description": "recover address which was used to sign message hash.", + "input": { + "message": "0xf334bf277b674260e85f1a3d2565d76463d63d29549ef4fa6d6833207576b5ba", + "signature":{ + "v": "0x1b", + "r": "0x4ee0d1719ed3f2f269394cf0d32edeeb2c42444088a84c0fa8683b1b3a5e542a", + "s": "0x6d1e4858120b82761d6e4baae2f86b64b6ee1a4f88b6374b5725b3a8fbc15d55" + }, + "isHashed": true + }, + "expectedResult": { + "status": "pass", + "output": "0xF848Ec62a79dF5c1b238ec7d9797C728136609d7" + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/recoverPublicKey.json b/caver-conformance-tests/Utils/Utils/recoverPublicKey.json new file mode 100644 index 000000000..81d44b120 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/recoverPublicKey.json @@ -0,0 +1,37 @@ +{ + "recoverPublicKey": [ + { + "id": "CONFORMANCE-UTILS-117", + "description": "recover public key which was used to sign message.", + "input": { + "message": "Some data", + "signature": { + "v": "0x1b", + "r": "0x155661771ef788c40a94cb86076261e0141f69c995fcc48182e0a36b1b36d1ba", + "s": "0x5a1bb2002ce21ac3670ede2c8c4568f4bb1d0a75b4192a1ac0dc441311ee7005" + } + }, + "expectedResult": { + "status": "pass", + "output": "0x833cd61adbe85f317544e09d1d161744c04c4ee60a90ad8eddd11c4ea2dfb0fd2ce39038ad91750c59254bfff58633de017cbaaa236f8397beefe10b21156586" + } + }, + { + "id": "CONFORMANCE-UTILS-118", + "description": "recover address which was used to sign message hash.", + "input": { + "message": "0x8ed2036502ed7f485b81feaec1c581d236a8b711e55a24077724879c8a263c2a", + "signature":{ + "v": "0x1b", + "r": "0xeee63404d01df1fc6f867f46543b72a012b0093a0dc3531a2fa537360d6b34aa", + "s": "0x57be2cde0debd3f47385ef24dc54a242583602a20c3fa78aa710ac86177cea14" + }, + "isHashed": true + }, + "expectedResult": { + "status": "pass", + "output": "0x4ec3c371b7e3e42ec77957ce26bb7f55b844e1ba41172ae47c5cda0b5443d81287e66e6b123d322fca59dc5793a5181c2a63636701acf67e0493866ae4c07c2e" + } + } + ] +} \ No newline at end of file diff --git a/caver-conformance-tests/Utils/Utils/stripHexPrefix.json b/caver-conformance-tests/Utils/Utils/stripHexPrefix.json new file mode 100644 index 000000000..74c45a013 --- /dev/null +++ b/caver-conformance-tests/Utils/Utils/stripHexPrefix.json @@ -0,0 +1,37 @@ +{ + "stripHexPrefix": [ + { + "id": "CONFORMANCE-UTILS-058", + "description": "prefix 0x must be removed.", + "input": { + "str": "0x123" + }, + "expectedResult": { + "status": "pass", + "output": "123" + } + }, + { + "id": "CONFORMANCE-UTILS-059", + "description": "prefix 0X must be removed.", + "input": { + "str": "0X123" + }, + "expectedResult": { + "status": "pass", + "output": "123" + } + }, + { + "id": "CONFORMANCE-UTILS-060", + "description": "the given string has no prefix.", + "input": { + "str": "123" + }, + "expectedResult": { + "status": "pass", + "output": "123" + } + } + ] +}