balance.rs 860 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: Apache-2.0
  2. use crate::build_solidity;
  3. use anchor_syn::idl::types::IdlInstruction;
  4. #[test]
  5. fn fallback() {
  6. let mut vm = build_solidity(
  7. r#"
  8. contract c {
  9. fallback() external {
  10. print("fallback");
  11. }
  12. }"#,
  13. );
  14. let data_account = vm.initialize_data_account();
  15. vm.function("new")
  16. .accounts(vec![("dataAccount", data_account)])
  17. .call();
  18. if let Some(idl) = &vm.stack[0].idl {
  19. let mut idl = idl.clone();
  20. idl.instructions.push(IdlInstruction {
  21. name: "extinct".to_string(),
  22. docs: None,
  23. accounts: vec![],
  24. args: vec![],
  25. returns: None,
  26. });
  27. vm.stack[0].idl = Some(idl);
  28. }
  29. vm.function("extinct").call();
  30. assert_eq!(vm.logs, "fallback");
  31. }