@@ -3937,6 +3937,209 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
39373937 BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" Deposit(uint256,bytes,uint256)" )));
39383938}
39393939
3940+ BOOST_AUTO_TEST_CASE (event_struct_memory_v2)
3941+ {
3942+ char const * sourceCode = R"(
3943+ pragma experimental ABIEncoderV2;
3944+ contract C {
3945+ struct S { uint a; }
3946+ event E(S);
3947+ function createEvent(uint x) public {
3948+ emit E(S(x));
3949+ }
3950+ }
3951+ )" ;
3952+ compileAndRun (sourceCode);
3953+ u256 x (42 );
3954+ callContractFunction (" createEvent(uint256)" , x);
3955+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
3956+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
3957+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (x));
3958+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
3959+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E((uint256))" )));
3960+ }
3961+
3962+ BOOST_AUTO_TEST_CASE (event_struct_storage_v2)
3963+ {
3964+ char const * sourceCode = R"(
3965+ pragma experimental ABIEncoderV2;
3966+ contract C {
3967+ struct S { uint a; }
3968+ event E(S);
3969+ S s;
3970+ function createEvent(uint x) public {
3971+ s.a = x;
3972+ emit E(s);
3973+ }
3974+ }
3975+ )" ;
3976+ compileAndRun (sourceCode);
3977+ u256 x (42 );
3978+ callContractFunction (" createEvent(uint256)" , x);
3979+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
3980+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
3981+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (x));
3982+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
3983+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E((uint256))" )));
3984+ }
3985+
3986+ BOOST_AUTO_TEST_CASE (event_dynamic_array_memory)
3987+ {
3988+ char const * sourceCode = R"(
3989+ contract C {
3990+ event E(uint[]);
3991+ function createEvent(uint x) public {
3992+ uint[] memory arr = new uint[](3);
3993+ arr[0] = x;
3994+ arr[1] = x + 1;
3995+ arr[2] = x + 2;
3996+ emit E(arr);
3997+ }
3998+ }
3999+ )" ;
4000+ compileAndRun (sourceCode);
4001+ u256 x (42 );
4002+ callContractFunction (" createEvent(uint256)" , x);
4003+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
4004+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
4005+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (0x20 , 3 , x, x + 1 , x + 2 ));
4006+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
4007+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E(uint256[])" )));
4008+ }
4009+
4010+ BOOST_AUTO_TEST_CASE (event_dynamic_array_memory_v2)
4011+ {
4012+ char const * sourceCode = R"(
4013+ pragma experimental ABIEncoderV2;
4014+ contract C {
4015+ event E(uint[]);
4016+ function createEvent(uint x) public {
4017+ uint[] memory arr = new uint[](3);
4018+ arr[0] = x;
4019+ arr[1] = x + 1;
4020+ arr[2] = x + 2;
4021+ emit E(arr);
4022+ }
4023+ }
4024+ )" ;
4025+ compileAndRun (sourceCode);
4026+ u256 x (42 );
4027+ callContractFunction (" createEvent(uint256)" , x);
4028+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
4029+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
4030+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (0x20 , 3 , x, x + 1 , x + 2 ));
4031+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
4032+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E(uint256[])" )));
4033+ }
4034+
4035+ BOOST_AUTO_TEST_CASE (event_dynamic_nested_array_memory_v2)
4036+ {
4037+ char const * sourceCode = R"(
4038+ pragma experimental ABIEncoderV2;
4039+ contract C {
4040+ event E(uint[][]);
4041+ function createEvent(uint x) public {
4042+ uint[][] memory arr = new uint[][](2);
4043+ arr[0] = new uint[](2);
4044+ arr[1] = new uint[](2);
4045+ arr[0][0] = x;
4046+ arr[0][1] = x + 1;
4047+ arr[1][0] = x + 2;
4048+ arr[1][1] = x + 3;
4049+ emit E(arr);
4050+ }
4051+ }
4052+ )" ;
4053+ compileAndRun (sourceCode);
4054+ u256 x (42 );
4055+ callContractFunction (" createEvent(uint256)" , x);
4056+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
4057+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
4058+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (0x20 , 2 , 0x40 , 0xa0 , 2 , x, x + 1 , 2 , x + 2 , x + 3 ));
4059+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
4060+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E(uint256[][])" )));
4061+ }
4062+
4063+ BOOST_AUTO_TEST_CASE (event_dynamic_array_storage)
4064+ {
4065+ char const * sourceCode = R"(
4066+ contract C {
4067+ event E(uint[]);
4068+ uint[] arr;
4069+ function createEvent(uint x) public {
4070+ arr.length = 3;
4071+ arr[0] = x;
4072+ arr[1] = x + 1;
4073+ arr[2] = x + 2;
4074+ emit E(arr);
4075+ }
4076+ }
4077+ )" ;
4078+ compileAndRun (sourceCode);
4079+ u256 x (42 );
4080+ callContractFunction (" createEvent(uint256)" , x);
4081+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
4082+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
4083+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (0x20 , 3 , x, x + 1 , x + 2 ));
4084+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
4085+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E(uint256[])" )));
4086+ }
4087+
4088+ BOOST_AUTO_TEST_CASE (event_dynamic_array_storage_v2)
4089+ {
4090+ char const * sourceCode = R"(
4091+ pragma experimental ABIEncoderV2;
4092+ contract C {
4093+ event E(uint[]);
4094+ uint[] arr;
4095+ function createEvent(uint x) public {
4096+ arr.length = 3;
4097+ arr[0] = x;
4098+ arr[1] = x + 1;
4099+ arr[2] = x + 2;
4100+ emit E(arr);
4101+ }
4102+ }
4103+ )" ;
4104+ compileAndRun (sourceCode);
4105+ u256 x (42 );
4106+ callContractFunction (" createEvent(uint256)" , x);
4107+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
4108+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
4109+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (0x20 , 3 , x, x + 1 , x + 2 ));
4110+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
4111+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E(uint256[])" )));
4112+ }
4113+
4114+ BOOST_AUTO_TEST_CASE (event_dynamic_nested_array_storage_v2)
4115+ {
4116+ char const * sourceCode = R"(
4117+ pragma experimental ABIEncoderV2;
4118+ contract C {
4119+ event E(uint[][]);
4120+ uint[][] arr;
4121+ function createEvent(uint x) public {
4122+ arr.length = 2;
4123+ arr[0].length = 2;
4124+ arr[1].length = 2;
4125+ arr[0][0] = x;
4126+ arr[0][1] = x + 1;
4127+ arr[1][0] = x + 2;
4128+ arr[1][1] = x + 3;
4129+ emit E(arr);
4130+ }
4131+ }
4132+ )" ;
4133+ compileAndRun (sourceCode);
4134+ u256 x (42 );
4135+ callContractFunction (" createEvent(uint256)" , x);
4136+ BOOST_REQUIRE_EQUAL (m_logs.size (), 1 );
4137+ BOOST_CHECK_EQUAL (m_logs[0 ].address , m_contractAddress);
4138+ BOOST_CHECK (m_logs[0 ].data == encodeArgs (0x20 , 2 , 0x40 , 0xa0 , 2 , x, x + 1 , 2 , x + 2 , x + 3 ));
4139+ BOOST_REQUIRE_EQUAL (m_logs[0 ].topics .size (), 1 );
4140+ BOOST_CHECK_EQUAL (m_logs[0 ].topics [0 ], dev::keccak256 (string (" E(uint256[][])" )));
4141+ }
4142+
39404143BOOST_AUTO_TEST_CASE (event_indexed_string)
39414144{
39424145 char const * sourceCode = R"(
0 commit comments