Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tests): Always use debug in tests #3542

Merged
merged 6 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ jobs:
-p "pallet-*"
-p gear-lazy-pages
-p gear-runtime-interface
-F debug
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ test-gcli-release: node-release

.PHONY: test-pallet
test-pallet:
@ ./scripts/gear.sh test pallet
@ ./scripts/gear.sh test pallet -F debug

.PHONY: test-pallet-release
test-pallet-release:
Expand Down
11 changes: 9 additions & 2 deletions pallets/gear/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ demo-init-wait = { workspace = true, optional = true }
wabt.workspace = true
hex.workspace = true
blake2-rfc.workspace = true
gstd = { workspace = true, features = ["debug"] }
gstd.workspace = true
demo-async.workspace = true
demo-async-init.workspace = true
demo-async-recursion.workspace = true
Expand Down Expand Up @@ -98,7 +98,7 @@ demo-compose.workspace = true
demo-constructor.workspace = true
demo-mul-by-const.workspace = true
demo-wait.workspace = true
demo-waiter = { workspace = true, features = ["debug"] } # The 'debug' feature is required for some assertion in tests
thecaralice marked this conversation as resolved.
Show resolved Hide resolved
demo-waiter.workspace = true
demo-wait-timeout.workspace = true
demo-wait-wake.workspace = true
demo-reserve-gas.workspace = true
Expand Down Expand Up @@ -195,3 +195,10 @@ runtime-benchmarks = [
runtime-benchmarks-checkers = []
try-runtime = ["frame-support/try-runtime"]
fuzz = ["pallet-gear-gas/fuzz", "common/fuzz"]
debug = [
"demo-async-tester/debug",
"demo-constructor/debug",
"demo-delayed-reservation-sender/debug",
"demo-waiter/debug",
"test-syscalls/debug",
]
28 changes: 16 additions & 12 deletions pallets/gear/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ fn delayed_reservations_sending_validation() {

run_to_next_block(None);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"{SENDING_EXPECT}: {:?}",
GstdError::Core(
Expand Down Expand Up @@ -377,7 +377,7 @@ fn delayed_reservations_sending_validation() {

run_for_blocks(wait_for + 1, None);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"{SENDING_EXPECT}: {:?}",
GstdError::Core(
Expand Down Expand Up @@ -492,7 +492,7 @@ fn default_wait_lock_timeout() {

run_to_block(expiration_block, None);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"ran into error-reply: {:?}",
GstdError::Timeout(expiration_block, expiration_block)
Expand Down Expand Up @@ -7402,7 +7402,7 @@ fn pay_program_rent_syscall_works() {

run_to_next_block(None);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"{PAY_PROGRAM_RENT_EXPECT}: {:?}",
GstdError::Core(ExtError::Execution(ExecutionError::NotEnoughValue).into())
Expand Down Expand Up @@ -7448,7 +7448,7 @@ fn pay_program_rent_syscall_works() {

run_to_next_block(None);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"{PAY_PROGRAM_RENT_EXPECT}: {:?}",
GstdError::Core(
Expand Down Expand Up @@ -8658,7 +8658,7 @@ fn test_create_program_with_value_lt_ed() {
// to send init message with value in invalid range.
assert_total_dequeued(1);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"Failed to create program: {:?}",
GstdError::Core(ExtError::Message(MessageError::InsufficientValue).into())
Expand Down Expand Up @@ -8712,7 +8712,7 @@ fn test_create_program_with_exceeding_value() {
// to send init message with value in invalid range.
assert_total_dequeued(1);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
format!(
"Failed to create program: {:?}",
GstdError::Core(ExtError::Execution(ExecutionError::NotEnoughValue).into())
Expand Down Expand Up @@ -8804,7 +8804,7 @@ fn demo_constructor_works() {

run_to_next_block(None);

let error_text = if cfg!(any(feature = "debug", debug_assertions)) {
let error_text = if cfg!(feature = "debug") {
"I just panic every time"
} else {
"no info"
Expand Down Expand Up @@ -9799,10 +9799,14 @@ fn mx_lock_ownership_exceedance() {

let get_lock_ownership_exceeded_trap = |command_msg_id| {
ActorExecutionErrorReplyReason::Trap(TrapExplanation::Panic(
format!(
"Message 0x{} has exceeded lock ownership time",
hex::encode(command_msg_id)
)
if cfg!(feature = "debug") {
format!(
"Message 0x{} has exceeded lock ownership time",
hex::encode(command_msg_id)
)
} else {
"no info".to_owned()
}
thecaralice marked this conversation as resolved.
Show resolved Hide resolved
.into(),
))
};
Expand Down
Loading