debug_buffer_format.rs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: Apache-2.0
  2. use crate::build_solidity_with_options;
  3. #[test]
  4. fn debug_buffer_format() {
  5. let mut runtime = build_solidity_with_options(
  6. r#"contract DebugBuffer {
  7. function multiple_prints() public {
  8. print("Hello!");
  9. print("I call seal_debug_message under the hood!");
  10. }
  11. function multiple_prints_then_revert() public {
  12. print("Hello!");
  13. print("I call seal_debug_message under the hood!");
  14. revert("sesa!!!");
  15. }
  16. }
  17. "#,
  18. true,
  19. true,
  20. );
  21. runtime.function("multiple_prints", [].to_vec());
  22. assert_eq!(
  23. runtime.printbuf,
  24. r#"print: Hello!,
  25. call: seal_debug_message=0,
  26. print: I call seal_debug_message under the hood!,
  27. call: seal_debug_message=0,
  28. "#
  29. );
  30. runtime.printbuf.clear();
  31. runtime.function_expect_failure("multiple_prints_then_revert", [].to_vec());
  32. assert_eq!(
  33. runtime.printbuf,
  34. r#"print: Hello!,
  35. call: seal_debug_message=0,
  36. print: I call seal_debug_message under the hood!,
  37. call: seal_debug_message=0,
  38. runtime_error: sesa!!! revert encountered in test.sol:10:17-23,
  39. call: seal_debug_message=0,
  40. "#
  41. );
  42. }