-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from BoostryJP/loop-test
Add load module for payload timeout verification
- Loading branch information
Showing
13 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright BOOSTRY Co., Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/// @title Loop 10000 | ||
contract Loop { | ||
|
||
constructor() {} | ||
|
||
/// loop 10000 | ||
function loop10000() public { | ||
for (uint256 i = 0; i < 10000; i++) {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Copyright BOOSTRY Co., Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
|
||
import secrets | ||
|
||
from eth_utils import keccak, to_checksum_address | ||
from coincurve import PublicKey | ||
from web3 import Web3 | ||
from web3.middleware import geth_poa_middleware | ||
|
||
from tests.config import WEB3_HTTP_PROVIDER, CHAIN_ID, DEPLOYED_CONTRACT_ADDRESS | ||
from tests.util import ContractUtils | ||
|
||
contract = ContractUtils.get_contract(DEPLOYED_CONTRACT_ADDRESS) | ||
web3 = Web3(Web3.HTTPProvider(WEB3_HTTP_PROVIDER)) | ||
web3.middleware_onion.inject(geth_poa_middleware, layer=0) | ||
web3.strict_bytes_type_checking = False | ||
|
||
|
||
for i in range(1000): | ||
private_key = keccak(secrets.token_bytes(32)) | ||
public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:] | ||
addr = to_checksum_address(keccak(public_key)[-20:]) | ||
nonce = web3.eth.get_transaction_count(addr) | ||
tx = contract.functions.loop10000().build_transaction( | ||
transaction={ | ||
"chainId": CHAIN_ID, | ||
"from": addr, | ||
"gas": 100000000, | ||
"gasPrice": 0, | ||
"nonce": nonce | ||
} | ||
) | ||
signed_tx = web3.eth.account.sign_transaction( | ||
transaction_dict=tx, private_key=private_key | ||
) | ||
tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction.hex()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Copyright BOOSTRY Co., Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
path = os.path.join(os.path.dirname(__file__), "../") | ||
sys.path.append(path) | ||
|
||
from tests.util import ContractUtils | ||
|
||
# Deploy | ||
args = [] | ||
contract_address, _, _ = ContractUtils.deploy_contract(args) | ||
|
||
print(f"DEPLOYED_CONTRACT_ADDRESS={contract_address}") |