|
6 | 6 | event_signature_to_log_topic, |
7 | 7 | ) |
8 | 8 |
|
| 9 | +from web3._utils.module_testing.event_contract import ( |
| 10 | + EVNT_CONTRACT_ABI, |
| 11 | + EVNT_CONTRACT_CODE, |
| 12 | + EVNT_CONTRACT_RUNTIME, |
| 13 | +) |
| 14 | +from web3._utils.module_testing.indexed_event_contract import ( |
| 15 | + IND_EVENT_CONTRACT_ABI, |
| 16 | + IND_EVENT_CONTRACT_CODE, |
| 17 | + IND_EVENT_CONTRACT_RUNTIME, |
| 18 | +) |
| 19 | + |
9 | 20 | CONTRACT_NESTED_TUPLE_SOURCE = """ |
10 | 21 | pragma solidity >=0.4.19 <0.6.0; |
11 | 22 | pragma experimental ABIEncoderV2; |
@@ -402,6 +413,121 @@ def emitter(web3_empty, Emitter, wait_for_transaction, wait_for_block, address_c |
402 | 413 | return emitter_contract |
403 | 414 |
|
404 | 415 |
|
| 416 | +@pytest.fixture() |
| 417 | +def EVENT_CONTRACT_CODE(): |
| 418 | + return EVNT_CONTRACT_CODE |
| 419 | + |
| 420 | + |
| 421 | +@pytest.fixture() |
| 422 | +def EVENT_CONTRACT_RUNTIME(): |
| 423 | + return EVNT_CONTRACT_RUNTIME |
| 424 | + |
| 425 | + |
| 426 | +@pytest.fixture() |
| 427 | +def EVENT_CONTRACT_ABI(): |
| 428 | + return EVNT_CONTRACT_ABI |
| 429 | + |
| 430 | + |
| 431 | +@pytest.fixture() |
| 432 | +def EVENT_CONTRACT( |
| 433 | + EVENT_CONTRACT_CODE, |
| 434 | + EVENT_CONTRACT_RUNTIME, |
| 435 | + EVENT_CONTRACT_ABI): |
| 436 | + return { |
| 437 | + 'bytecode': EVENT_CONTRACT_CODE, |
| 438 | + 'bytecode_runtime': EVENT_CONTRACT_RUNTIME, |
| 439 | + 'abi': EVENT_CONTRACT_ABI, |
| 440 | + } |
| 441 | + |
| 442 | + |
| 443 | +@pytest.fixture() |
| 444 | +def EventContract(web3_empty, EVENT_CONTRACT): |
| 445 | + web3 = web3_empty |
| 446 | + return web3.eth.contract(**EVENT_CONTRACT) |
| 447 | + |
| 448 | + |
| 449 | +@pytest.fixture() |
| 450 | +def event_contract( |
| 451 | + web3_empty, |
| 452 | + EventContract, |
| 453 | + wait_for_transaction, |
| 454 | + wait_for_block, |
| 455 | + address_conversion_func): |
| 456 | + |
| 457 | + web3 = web3_empty |
| 458 | + |
| 459 | + wait_for_block(web3) |
| 460 | + deploy_txn_hash = EventContract.constructor().transact({ |
| 461 | + 'from': web3.eth.coinbase, 'gas': 1000000 |
| 462 | + }) |
| 463 | + deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) |
| 464 | + contract_address = address_conversion_func(deploy_receipt['contractAddress']) |
| 465 | + |
| 466 | + bytecode = web3.eth.getCode(contract_address) |
| 467 | + assert bytecode == EventContract.bytecode_runtime |
| 468 | + event_contract = EventContract(address=contract_address) |
| 469 | + assert event_contract.address == contract_address |
| 470 | + return event_contract |
| 471 | + |
| 472 | + |
| 473 | +@pytest.fixture() |
| 474 | +def INDEXED_EVENT_CONTRACT_CODE(): |
| 475 | + return IND_EVENT_CONTRACT_CODE |
| 476 | + |
| 477 | + |
| 478 | +@pytest.fixture() |
| 479 | +def INDEXED_EVENT_CONTRACT_RUNTIME(): |
| 480 | + return IND_EVENT_CONTRACT_RUNTIME |
| 481 | + |
| 482 | + |
| 483 | +@pytest.fixture() |
| 484 | +def INDEXED_EVENT_CONTRACT_ABI(): |
| 485 | + return IND_EVENT_CONTRACT_ABI |
| 486 | + |
| 487 | + |
| 488 | +@pytest.fixture() |
| 489 | +def INDEXED_EVENT_CONTRACT( |
| 490 | + INDEXED_EVENT_CONTRACT_CODE, |
| 491 | + INDEXED_EVENT_CONTRACT_RUNTIME, |
| 492 | + INDEXED_EVENT_CONTRACT_ABI): |
| 493 | + return { |
| 494 | + 'bytecode': INDEXED_EVENT_CONTRACT_CODE, |
| 495 | + 'bytecode_runtime': INDEXED_EVENT_CONTRACT_RUNTIME, |
| 496 | + 'abi': INDEXED_EVENT_CONTRACT_ABI, |
| 497 | + } |
| 498 | + |
| 499 | + |
| 500 | +@pytest.fixture() |
| 501 | +def IndexedEventContract(web3_empty, INDEXED_EVENT_CONTRACT): |
| 502 | + web3 = web3_empty |
| 503 | + return web3.eth.contract(**INDEXED_EVENT_CONTRACT) |
| 504 | + |
| 505 | + |
| 506 | +@pytest.fixture() |
| 507 | +def indexed_event( |
| 508 | + web3_empty, |
| 509 | + IndexedEventContract, |
| 510 | + wait_for_transaction, |
| 511 | + wait_for_block, |
| 512 | + address_conversion_func): |
| 513 | + |
| 514 | + web3 = web3_empty |
| 515 | + |
| 516 | + wait_for_block(web3) |
| 517 | + deploy_txn_hash = IndexedEventContract.constructor().transact({ |
| 518 | + 'from': web3.eth.coinbase, |
| 519 | + 'gas': 1000000 |
| 520 | + }) |
| 521 | + deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) |
| 522 | + contract_address = address_conversion_func(deploy_receipt['contractAddress']) |
| 523 | + |
| 524 | + bytecode = web3.eth.getCode(contract_address) |
| 525 | + assert bytecode == IndexedEventContract.bytecode_runtime |
| 526 | + indexed_event_contract = IndexedEventContract(address=contract_address) |
| 527 | + assert indexed_event_contract.address == contract_address |
| 528 | + return indexed_event_contract |
| 529 | + |
| 530 | + |
405 | 531 | CONTRACT_ARRAYS_SOURCE = """ |
406 | 532 | contract ArraysContract { |
407 | 533 |
|
@@ -698,6 +824,7 @@ class LogFunctions: |
698 | 824 | LogDoubleWithIndex = 9 |
699 | 825 | LogTripleWithIndex = 10 |
700 | 826 | LogQuadrupleWithIndex = 11 |
| 827 | + LogBytes = 12 |
701 | 828 |
|
702 | 829 |
|
703 | 830 | @pytest.fixture() |
|
0 commit comments