Skip to content

Commit

Permalink
test(engine): fix infinite loop test (#873)
Browse files Browse the repository at this point in the history
Description
---
Fix infinite loop test

Motivation and Context
---
Exact string matching cannot be used for this error

```
---- test_break_infinity_loop stdout ----
note: panic did not contain expected string
      panic message: `"called `Result::unwrap()` on an `Err` value: Transaction failed: Execution failure: RuntimeError: unreachable\n    at tari_free (<module>[328]:0x23b3c)"`,
 expected substring: `"called `Result::unwrap()` on an `Err` value: Transaction failed: Execution failure: RuntimeError: unreachable\n    at tari_free (<module>[327]:0x2390c)"`
```

https://github.com/tari-project/tari-dan/actions/runs/7406320369/job/20150567753?pr=872

How Has This Been Tested?
---
Test passes

What process can a PR reviewer use to test or verify this change?
---
CI

Breaking Changes
---

- [x] None
- [ ] Requires data directory to be deleted
- [ ] Other - Please specify
  • Loading branch information
sdbondi authored Jan 4, 2024
1 parent f9c91ea commit 8f7c893
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions dan_layer/engine/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use tari_template_lib::{
models::{Amount, ComponentAddress, NonFungibleAddress},
prelude::{NonFungibleId, ResourceAddress},
};
use tari_template_test_tooling::{SubstateType, TemplateTest};
use tari_template_test_tooling::{support::assert_error::assert_reject_reason, SubstateType, TemplateTest};
use tari_transaction::Transaction;
use tari_transaction_manifest::ManifestValue;
use tari_utilities::hex::to_hex;
Expand Down Expand Up @@ -294,13 +294,17 @@ fn test_random() {
}

#[test]
#[should_panic(
expected = "called `Result::unwrap()` on an `Err` value: Transaction failed: Execution failure: RuntimeError: \
unreachable\n at tari_free (<module>[327]:0x2390c)"
)]
fn test_break_infinity_loop() {
let mut template_test = TemplateTest::new(vec!["tests/templates/infinity_loop"]);
template_test.call_function::<()>("InfinityLoopTest", "infinity_loop", args![], vec![]);
fn test_errors_on_infinite_loop() {
let mut test = TemplateTest::new(vec!["tests/templates/infinity_loop"]);
let reason = test.execute_expect_failure(
Transaction::builder()
.call_function(test.get_template_address("InfinityLoopTest"), "infinity_loop", args![])
.sign(test.get_test_secret_key())
.build(),
vec![],
);
// Transaction failed: Execution failure: RuntimeError: unreachable\n at tari_free (<module>[327]:0x2390c)
assert_reject_reason(reason, wasmer::RuntimeError::new("unreachable"))
}

mod errors {
Expand Down

0 comments on commit 8f7c893

Please sign in to comment.