-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[graphql] Add support for clever error resolution in graphql
- Loading branch information
Showing
7 changed files
with
747 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
248 changes: 248 additions & 0 deletions
248
crates/sui-graphql-e2e-tests/tests/errors/clever_errors.exp
Large diffs are not rendered by default.
Oops, something went wrong.
233 changes: 233 additions & 0 deletions
233
crates/sui-graphql-e2e-tests/tests/errors/clever_errors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --protocol-version 39 --addresses P0=0x0 P1=0x0 --accounts A --simulator | ||
|
||
//# publish --upgradeable --sender A | ||
module P0::m { | ||
#[error] | ||
const ImAU8: u8 = 0; | ||
|
||
#[error] | ||
const ImAU16: u16 = 0; | ||
|
||
#[error] | ||
const ImAU32: u32 = 0; | ||
|
||
#[error] | ||
const ImAU64: u64 = 0; | ||
|
||
#[error] | ||
const ImAU128: u128 = 0; | ||
|
||
#[error] | ||
const ImAU256: u256 = 0; | ||
|
||
#[error] | ||
const ImABool: bool = true; | ||
|
||
#[error] | ||
const ImAAddress: address = @0; | ||
|
||
#[error] | ||
const ImAString: vector<u8> = b"This is a string"; | ||
|
||
#[error] | ||
const ImNotAString: vector<u8> = vector[1,2,3,4,5]; | ||
|
||
public fun callU8() { | ||
abort ImAU8 | ||
} | ||
|
||
public fun callU16() { | ||
abort ImAU16 | ||
} | ||
|
||
public fun callU32() { | ||
abort ImAU32 | ||
} | ||
|
||
public fun callU64() { | ||
abort ImAU64 | ||
} | ||
|
||
public fun callU128() { | ||
abort ImAU128 | ||
} | ||
|
||
public fun callU256() { | ||
abort ImAU256 | ||
} | ||
|
||
public fun callAddress() { | ||
abort ImAAddress | ||
} | ||
|
||
public fun callString() { | ||
abort ImAString | ||
} | ||
|
||
public fun callBytevec() { | ||
abort ImNotAString | ||
} | ||
|
||
public fun normalAbort() { | ||
abort 0 | ||
} | ||
|
||
public fun assertLineNo() { | ||
assert!(false); | ||
} | ||
} | ||
|
||
//# run P0::m::callU8 | ||
|
||
//# run P0::m::callU16 | ||
|
||
//# run P0::m::callU32 | ||
|
||
//# run P0::m::callU64 | ||
|
||
//# run P0::m::callU128 | ||
|
||
//# run P0::m::callU256 | ||
|
||
//# run P0::m::callAddress | ||
|
||
//# run P0::m::callString | ||
|
||
//# run P0::m::callBytevec | ||
|
||
//# run P0::m::normalAbort | ||
|
||
//# run P0::m::assertLineNo | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql | ||
{ | ||
transactionBlocks(last: 11) { | ||
nodes { | ||
effects { | ||
status | ||
errors | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# upgrade --package P0 --upgrade-capability 1,1 --sender A | ||
// Upgrade the module with new error values but using the same constant names | ||
// (etc) to make sure we properly resolve the module location for clever | ||
// errors. | ||
module P0::m { | ||
#[error] | ||
const ImAU8: u8 = 1; | ||
|
||
#[error] | ||
const ImAU16: u16 = 1; | ||
|
||
#[error] | ||
const ImAU32: u32 = 1; | ||
|
||
#[error] | ||
const ImAU64: u64 = 1; | ||
|
||
#[error] | ||
const ImAU128: u128 = 1; | ||
|
||
#[error] | ||
const ImAU256: u256 = 1; | ||
|
||
#[error] | ||
const ImABool: bool = false; | ||
|
||
#[error] | ||
const ImAAddress: address = @1; | ||
|
||
#[error] | ||
const ImAString: vector<u8> = b"This is a string in v2"; | ||
|
||
#[error] | ||
const ImNotAString: vector<u8> = vector[1,2,3,4,5, 6]; | ||
|
||
public fun callU8() { | ||
abort ImAU8 | ||
} | ||
|
||
public fun callU16() { | ||
abort ImAU16 | ||
} | ||
|
||
public fun callU32() { | ||
abort ImAU32 | ||
} | ||
|
||
public fun callU64() { | ||
abort ImAU64 | ||
} | ||
|
||
public fun callU128() { | ||
abort ImAU128 | ||
} | ||
|
||
public fun callU256() { | ||
abort ImAU256 | ||
} | ||
|
||
public fun callAddress() { | ||
abort ImAAddress | ||
} | ||
|
||
public fun callString() { | ||
abort ImAString | ||
} | ||
|
||
public fun callBytevec() { | ||
abort ImNotAString | ||
} | ||
|
||
public fun normalAbort() { | ||
abort 0 | ||
} | ||
|
||
public fun assertLineNo() { | ||
assert!(false); | ||
} | ||
} | ||
|
||
//# run P0::m::callU8 | ||
|
||
//# run P0::m::callU16 | ||
|
||
//# run P0::m::callU32 | ||
|
||
//# run P0::m::callU64 | ||
|
||
//# run P0::m::callU128 | ||
|
||
//# run P0::m::callU256 | ||
|
||
//# run P0::m::callAddress | ||
|
||
//# run P0::m::callString | ||
|
||
//# run P0::m::callBytevec | ||
|
||
//# run P0::m::normalAbort | ||
|
||
//# run P0::m::assertLineNo | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql | ||
{ | ||
transactionBlocks(last: 9) { | ||
nodes { | ||
effects { | ||
status | ||
errors | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.