Skip to content

Commit 6a8fae9

Browse files
gnd(test): Document lowercase hex requirement for assertions
graph-node returns all hex-encoded values (addresses, tx hashes, bytes) in lowercase. Add a note in the Assertions section's comparison behavior table and in Tips & Best Practices. Event inputs are normalised automatically and can be mixed case. Also fix the transfer.json fixture assertion to use lowercase token ID.
1 parent 1093860 commit 6a8fae9

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

gnd/docs/gnd-test.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,24 @@ GraphQL queries to validate the indexed entity state after processing all blocks
383383
| Arrays | **Order-insensitive** (set comparison) |
384384
| String vs Number | Coerced — `"123"` matches `123` |
385385
| Nulls/Booleans | Strict equality |
386+
| Hex strings | **Must be lowercase** — graph-node returns all hex values in lowercase |
386387

387-
**Important:** Arrays are compared as sets (order doesn't matter). If you need ordered results, use `orderBy` in your GraphQL query:
388+
**Important:** Arrays are compared as sets (order doesn't matter).
389+
390+
**Important:** graph-node returns all hex-encoded values (addresses, transaction hashes, byte arrays) in **lowercase**. Expected values in assertions must match exactly — mixed-case hex will not match:
391+
392+
```json
393+
{
394+
"expected": {
395+
"transfer": {
396+
"from": "0xaaaa000000000000000000000000000000000000", // ✅ lowercase
397+
"to": "0xBBBB000000000000000000000000000000000000" // ❌ will not match
398+
}
399+
}
400+
}
401+
```
402+
403+
Note: hex values in event inputs (`params`, `address`) are normalized automatically and can be mixed case. If you need ordered results, use `orderBy` in your GraphQL query:
388404

389405
```json
390406
{
@@ -592,23 +608,33 @@ my-subgraph/
592608

593609
## Tips & Best Practices
594610

595-
### Use Lowercase Addresses
611+
### Use Lowercase Hex in Assertions
596612

597-
Always use lowercase hex addresses with `0x` prefix:
613+
graph-node returns **all** hex-encoded values in lowercase — addresses, transaction hashes, and any `Bytes`/`ID` fields. Expected values in assertions must use lowercase hex:
598614

599615
```json
600616
{
601-
"address": "0x731a10897d267e19b34503ad902d0a29173ba4b1" // ✅ Correct
617+
"expected": {
618+
"transfer": {
619+
"from": "0xaaaa000000000000000000000000000000000000" // ✅ lowercase
620+
}
621+
}
602622
}
603623
```
604624

605625
Not:
606626
```json
607627
{
608-
"address": "0x731A10897D267E19B34503Ad902d0A29173Ba4B1" // ❌ Mixed case
628+
"expected": {
629+
"transfer": {
630+
"from": "0xAAAA000000000000000000000000000000000000" // ❌ will not match
631+
}
632+
}
609633
}
610634
```
611635

636+
Event inputs (`address`, `params`) are normalized automatically and can be mixed case.
637+
612638
### Test One Thing at a Time
613639

614640
Write focused tests that validate a single behavior:

gnd/tests/fixtures/gnd_test/subgraph/tests/transfer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"assertions": [
5151
{
5252
"query": "{ tokens { id name symbol decimals } }",
53-
"expected": { "tokens": [ { "id": "0x9623063377AD1B27544C965cCd7342f7EA7e88C7", "name": "TheGraph", "symbol": "GRT", "decimals": 18 } ] }
53+
"expected": { "tokens": [ { "id": "0x9623063377ad1b27544c965ccd7342f7ea7e88c7", "name": "TheGraph", "symbol": "GRT", "decimals": 18 } ] }
5454
},
5555
{
5656
"query": "{ accounts { id balances { token { symbol } amount } } }",

0 commit comments

Comments
 (0)