# 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"
      }
    }
  ]
}
```
