@@ -49,13 +49,19 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer
49
49
m_enforceViaYul(enforceViaYul)
50
50
{
51
51
using namespace std ::placeholders;
52
- m_builtins
53
- = {{" smoke" ,
54
- {
55
- {" test0()" , std::bind (&SemanticTest::builtinSmokeTest, this , _1)},
56
- {" test1(uint256)" , std::bind (&SemanticTest::builtinSmokeTest, this , _1)},
57
- {" test2(uint256,uint256)" , std::bind (&SemanticTest::builtinSmokeTest, this , _1)},
58
- }}};
52
+ m_builtins = {
53
+ {" smoke" ,
54
+ {
55
+ {" test0()" , std::bind (&SemanticTest::builtinSmokeTest, this , _1)},
56
+ {" test1(uint256)" , std::bind (&SemanticTest::builtinSmokeTest, this , _1)},
57
+ {" test2(uint256,uint256)" , std::bind (&SemanticTest::builtinSmokeTest, this , _1)},
58
+ }},
59
+ {" contract" ,
60
+ {
61
+ {" balance()" , std::bind (&SemanticTest::builtinContractBalance, this , _1)},
62
+ {" balance(uint256)" , std::bind (&SemanticTest::builtinContractBalance, this , _1)},
63
+ }},
64
+ };
59
65
60
66
string choice = m_reader.stringSetting (" compileViaYul" , " default" );
61
67
if (choice == " also" )
@@ -401,3 +407,16 @@ bytes SemanticTest::builtinSmokeTest(FunctionCall const& call)
401
407
result += util::toBigEndian (u256{call.arguments .parameters .at (i).rawBytes });
402
408
return result;
403
409
}
410
+
411
+ bytes SemanticTest::builtinContractBalance (FunctionCall const & call)
412
+ {
413
+ assert (call.arguments .parameters .size () <= 1 );
414
+ if (call.arguments .parameters .empty ())
415
+ return util::toBigEndian (SolidityExecutionFramework::balanceAt (m_contractAddress));
416
+ else
417
+ {
418
+ h160 address{util::fromHex (call.arguments .parameters .at (0 ).rawString )};
419
+ return util::toBigEndian (SolidityExecutionFramework::balanceAt (address));
420
+ }
421
+ return bytes{};
422
+ }
0 commit comments