Skip to content

Commit

Permalink
Review iota-graphql test coverage (#4135)
Browse files Browse the repository at this point in the history
* documentation: review iota-graphql test coverage

* documentation: reference the transactional test runner

* fix: refer tests.rs module

* fix: coverage for dynamic queries

* fix: coverage for filter options WIP

* fix: restructure coverage

* docs: Add missing queries

* fix: location paths

* fix: format

* fix: add missing filter options

* fix: remove link

* fix: graphql highlights
  • Loading branch information
samuel-rufi authored Nov 28, 2024
1 parent 1dd90ac commit 64bca64
Show file tree
Hide file tree
Showing 24 changed files with 2,574 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/iota-graphql-e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
End-to-end tests for GraphQL service, built on top of the transactional test
runner.

# Testing through the transactional test runner

This crate specifically tests GraphQL queries in an e2e manner against the Indexer database.
The tests are executed through the [transactional test runner](../iota-transactional-test-runner), mediated by the [test.rs](tests/tests.rs) module.

Each test is defined in a `.move` file, which contains various statements that are executed in a transactional manner.
In addition to the `.move` file, there is a corresponding `.exp` file that contains the expected output of the transactional test.

# Local Set-up

These tests require a running instance of the `postgres` service, with a
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
Query: `executeTransactionBlock`

```graphql
mutation {
executeTransactionBlock(txBytes: $tx, signatures: $sigs) {
effects {
transactionBlock {
digest
}
status
lamportVersion
errors
dependencies {
edges {
node {
digest
bcs
}
}
}
gasEffects {
__typename
gasObject {
digest
storageRebate
bcs
}
gasSummary {
computationCost
computationCostBurned
storageCost
storageRebate
nonRefundableStorageFee
}
}
unchangedSharedObjects {
edges {
node {
__typename
}
}
}
objectChanges {
edges {
node {
idCreated
idDeleted
}
}
}
balanceChanges {
edges {
node {
amount
}
}
}
events {
edges {
node {
timestamp
}
}
}
timestamp
epoch {
referenceGasPrice
endTimestamp
totalCheckpoints
totalTransactions
totalGasFees
totalStakeRewards
fundSize
netInflow
fundInflow
fundOutflow
systemStateVersion
iotaTotalSupply
iotaTreasuryCapId
liveObjectSetDigest
}
checkpoint {
previousCheckpointDigest
networkTotalTransactions
}
bcs
}
errors
}
}
```

tested by [crates/iota-graphql-rpc/tests/e2e_tests.rs](../../../iota-graphql-rpc/tests/e2e_tests.rs):

```graphql
{
executeTransactionBlock(txBytes: $tx, signatures: $sigs) {
effects {
transactionBlock {
digest
}
}
errors
}
}
```

tested by [crates/iota-graphql-rpc/tests/e2e_tests.rs](../../../iota-graphql-rpc/tests/e2e_tests.rs):

```graphql
mutation {
executeTransactionBlock(txBytes: "{}", signatures: "{}") {
effects {
status
}
}
}
```
191 changes: 191 additions & 0 deletions crates/iota-graphql-e2e-tests/coverage/query/address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
Query: `address`

```graphql
{
address(address: "0x1") {
address
objects {
edges {
node {
digest
storageRebate
bcs
}
}
}
balance {
coinObjectCount
totalBalance
}
balances {
edges {
node {
coinObjectCount
totalBalance
}
}
}
coins {
edges {
node {
digest
storageRebate
bcs
coinBalance
}
}
}
stakedIotas {
edges {
node {
digest
storageRebate
bcs
poolId
principal
estimatedReward
}
}
}
transactionBlocks {
edges {
node {
digest
bcs
}
}
}
}
}
```

tested by [crates/iota-graphql-e2e-tests/tests/call/owned_objects.move](../../../iota-graphql-e2e-tests/tests/call/owned_objects.move):

```graphql
//# run-graphql
{
address(address: "0x42") {
objects {
edges {
node {
owner {
__typename
... on AddressOwner {
owner {
address
}
}
}
}
}
}
}
}
```

tested by [crates/iota-graphql-e2e-tests/tests/transaction_block_effects/balance_changes.move](../../../iota-graphql-e2e-tests/tests/transaction_block_effects/balance_changes.move):

```graphql
//# run-graphql
{
address(address: "@{C}") {
transactionBlocks(last: 1) {
nodes {
effects {
balanceChanges {
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
edges {
node {
amount
}
cursor
}
}
}
}
}
}
}
```

tested by [crates/iota-graphql-e2e-tests/tests/consistency/coins.move](../../../iota-graphql-e2e-tests/tests/consistency/coins.move):

```graphql
//# run-graphql
{
queryCoins: coins(type: "@{P0}::fake::FAKE") {
edges {
cursor
node {
owner {
... on AddressOwner {
owner {
address
coins(type: "@{P0}::fake::FAKE") {
edges {
cursor
node {
contents {
json
}
}
}
}
}
}
}
contents {
json
}
}
}
}
addressCoinsA: address(address: "@{A}") {
coins(type: "@{P0}::fake::FAKE") {
edges {
cursor
node {
contents {
json
}
}
}
}
}
addressCoinsB: address(address: "@{B}") {
coins(type: "@{P0}::fake::FAKE") {
edges {
cursor
node {
contents {
json
}
}
}
}
}
}
```

tested by [crates/iota-graphql-e2e-tests/tests/consistency/staked_iota.move](../../../iota-graphql-e2e-tests/tests/consistency/staked_iota.move):

```graphql
//# run-graphql
{
address(address: "@{C}") {
stakedIotas {
edges {
cursor
node {
principal
}
}
}
}
}
```
43 changes: 43 additions & 0 deletions crates/iota-graphql-e2e-tests/coverage/query/availableRange.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Query: `availableRange`

```graphql
{
availableRange {
first {
digest
}
last {
digest
}
}
}
```

tested by [crates/iota-graphql-e2e-tests/tests/available_range/available_range.move](../../../iota-graphql-e2e-tests/tests/available_range/available_range.move):

```graphql
//# run-graphql
{
availableRange {
first {
digest
sequenceNumber
}
last {
digest
sequenceNumber
}
}

first: checkpoint(id: { sequenceNumber: 0 } ) {
digest
sequenceNumber
}

last: checkpoint {
digest
sequenceNumber
}
}
```

16 changes: 16 additions & 0 deletions crates/iota-graphql-e2e-tests/coverage/query/chainIdentifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Query: `chainIdentifier`

```graphql
{
chainIdentifier
}
```

tested by [crates/iota-graphql-e2e-tests/tests/epoch/chain_identifier.move](../../../iota-graphql-e2e-tests/tests/epoch/chain_identifier.move):

```graphql
//# run-graphql
{
chainIdentifier
}
```
Loading

0 comments on commit 64bca64

Please sign in to comment.