| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // SPDX-License-Identifier: Apache-2.0
- use crate::{build_solidity, BorshToken};
- use num_bigint::BigInt;
- #[test]
- fn constant() {
- let mut vm = build_solidity(
- r#"
- library Library {
- uint256 internal constant STATIC = 42;
- }
- contract foo {
- function f() public returns (uint) {
- uint a = Library.STATIC;
- return a;
- }
- }
- "#,
- );
- let data_account = vm.initialize_data_account();
- vm.function("new")
- .accounts(vec![("dataAccount", data_account)])
- .call();
- let returns = vm.function("f").call().unwrap();
- assert_eq!(
- returns,
- BorshToken::Uint {
- width: 256,
- value: BigInt::from(42u8)
- }
- );
- let mut vm = build_solidity(
- r#"
- contract C {
- uint256 public constant STATIC = 42;
- }
- contract foo {
- function f() public returns (uint) {
- uint a = C.STATIC;
- return a;
- }
- }
- "#,
- );
- let data_account = vm.initialize_data_account();
- vm.function("new")
- .accounts(vec![("dataAccount", data_account)])
- .call();
- let returns = vm.function("f").call().unwrap();
- assert_eq!(
- returns,
- BorshToken::Uint {
- width: 256,
- value: BigInt::from(42u8)
- }
- );
- }
|