Skip to content

Commit c306463

Browse files
tests: Refactor IDL tests (#2573)
1 parent cf057ac commit c306463

26 files changed

Lines changed: 103 additions & 117 deletions

.github/workflows/reusable-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ jobs:
443443
path: tests/anchor-cli-account
444444
- cmd: cd tests/bench && anchor test --skip-lint
445445
path: tests/bench
446-
- cmd: cd tests/idl-build && ./test.sh
447-
path: tests/idl-build
446+
- cmd: cd tests/idl && ./test.sh
447+
path: tests/idl
448448
steps:
449449
- uses: actions/checkout@v3
450450
- uses: ./.github/actions/setup/

tests/idl-build/Anchor.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/idl-build/gen_testdata.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/idl/Anchor.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[features]
2+
seeds = true
3+
4+
[programs.localnet]
5+
external = "Externa1111111111111111111111111111111111111"
6+
generics = "Generics111111111111111111111111111111111111"
7+
idl = "id11111111111111111111111111111111111111111"
8+
relations_derivation = "Re1ationsDerivation111111111111111111111111"
9+
10+
[provider]
11+
cluster = "localnet"
12+
wallet = "~/.config/solana/id.json"
13+
14+
[scripts]
15+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

tests/idl/generate.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
idls_dir=$PWD/idls
4+
5+
cd programs/idl
6+
anchor idl parse --file src/lib.rs -o $idls_dir/idl_parse_exp.json
7+
anchor idl build -o $idls_dir/idl_build_exp.json
8+
9+
cd ../generics
10+
anchor idl build -o $idls_dir/generics_build_exp.json
11+
12+
cd ../relations-derivation
13+
anchor idl build -o $idls_dir/relations_build_exp.json

tests/idl-build/tests/testdata/generics_build_exp.json renamed to tests/idl/idls/generics_build_exp.json

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"version": "0.1.0",
3-
"name": "example_program",
4-
"docs": [
5-
"This is an example program used for testing"
6-
],
3+
"name": "generics",
74
"instructions": [
85
{
96
"name": "generic",
@@ -77,6 +74,18 @@
7774
}
7875
],
7976
"types": [
77+
{
78+
"name": "Baz",
79+
"type": {
80+
"kind": "struct",
81+
"fields": [
82+
{
83+
"name": "someField",
84+
"type": "u8"
85+
}
86+
]
87+
}
88+
},
8089
{
8190
"name": "GenericEnum",
8291
"generics": [
@@ -404,18 +413,6 @@
404413
}
405414
]
406415
}
407-
},
408-
{
409-
"name": "Baz",
410-
"type": {
411-
"kind": "struct",
412-
"fields": [
413-
{
414-
"name": "someField",
415-
"type": "u8"
416-
}
417-
]
418-
}
419416
}
420417
]
421418
}

tests/idl-build/tests/testdata/idl_build_exp.json renamed to tests/idl/idls/idl_build_exp.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"version": "0.1.0",
3-
"name": "example_program",
3+
"name": "idl",
44
"docs": [
5-
"This is an example program used for testing"
5+
"IDL test program documentation."
66
],
77
"constants": [
88
{
@@ -475,6 +475,18 @@
475475
}
476476
],
477477
"types": [
478+
{
479+
"name": "external::Baz",
480+
"type": {
481+
"kind": "struct",
482+
"fields": [
483+
{
484+
"name": "someField",
485+
"type": "u8"
486+
}
487+
]
488+
}
489+
},
478490
{
479491
"name": "BarStruct",
480492
"docs": [
@@ -658,18 +670,6 @@
658670
}
659671
]
660672
}
661-
},
662-
{
663-
"name": "some_external_program::Baz",
664-
"type": {
665-
"kind": "struct",
666-
"fields": [
667-
{
668-
"name": "someField",
669-
"type": "u8"
670-
}
671-
]
672-
}
673673
}
674674
],
675675
"events": [
@@ -684,7 +684,7 @@
684684
{
685685
"name": "externalBaz",
686686
"type": {
687-
"defined": "some_external_program::Baz"
687+
"defined": "external::Baz"
688688
},
689689
"index": false
690690
},

tests/idl-build/tests/testdata/idl_parse_exp.json renamed to tests/idl/idls/idl_parse_exp.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"version": "0.1.0",
3-
"name": "example_program",
3+
"name": "idl",
44
"docs": [
5-
"This is an example program used for testing"
5+
"IDL test program documentation."
66
],
77
"constants": [
88
{
@@ -672,7 +672,7 @@
672672
{
673673
"name": "externalBaz",
674674
"type": {
675-
"defined": "some_external_program::Baz"
675+
"defined": "external::Baz"
676676
},
677677
"index": false
678678
},
File renamed without changes.

0 commit comments

Comments
 (0)