forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ae6c73
commit 4882681
Showing
6 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
.../tests/src/test/java/org/hyperledger/besu/tests/acceptance/bftsoak/BftMiningSoakTest.java
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,126 @@ | ||
/* | ||
* Copyright ConsenSys AG. | ||
* | ||
* 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 | ||
*/ | ||
package org.hyperledger.besu.tests.acceptance.bftsoak; | ||
|
||
import org.hyperledger.besu.tests.acceptance.bft.BftAcceptanceTestParameterization; | ||
import org.hyperledger.besu.tests.acceptance.bft.ParameterizedBftTestBase; | ||
import org.hyperledger.besu.tests.acceptance.dsl.account.Account; | ||
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; | ||
|
||
import java.math.BigInteger; | ||
|
||
import org.junit.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
public class BftMiningSoakTest extends ParameterizedBftTestBase { | ||
|
||
@ParameterizedTest(name = "{index}: {0}") | ||
@MethodSource("factoryFunctions") | ||
public void shouldMineOnMultipleNodes() throws Exception { | ||
final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); | ||
final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); | ||
final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); | ||
final BesuNode minerNode4 = nodeFactory.createNode(besu, "miner4"); | ||
cluster.start(minerNode1, minerNode2, minerNode3, minerNode4); | ||
|
||
cluster.verify(blockchain.reachesHeight(minerNode1, 1, 85)); | ||
|
||
final Account sender = accounts.createAccount("account1"); | ||
final Account receiver = accounts.createAccount("account2"); | ||
receiver.balanceEquals(20); | ||
|
||
BigInteger currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the beginning: " + currentReceiverBalance); | ||
BigInteger chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
for (int i = 0; i < 5; i++) { | ||
BigInteger currentSenderBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(sender, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance: " + currentSenderBalance); | ||
minerNode1.execute(accountTransactions.createTransfer(sender, 50)); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
} | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
cluster.verify(sender.balanceEquals(150)); | ||
|
||
minerNode2.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 1)); | ||
cluster.verify(receiver.balanceEquals(1)); | ||
|
||
minerNode3.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 2)); | ||
cluster.verify(receiver.balanceEquals(3)); | ||
|
||
minerNode4.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 3)); | ||
cluster.verify(receiver.balanceEquals(6)); | ||
|
||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
currentReceiverBalance = | ||
minerNode1.execute(ethTransactions.getBalanceAtBlock(receiver, BigInteger.valueOf(0))); | ||
System.out.println("MRW: Rich donor balance at the end: " + currentReceiverBalance); | ||
Thread.sleep(5000); | ||
chainHeight = minerNode1.execute(ethTransactions.blockNumber()); | ||
System.out.println("MRW: Current chain height: " + chainHeight); | ||
} | ||
|
||
/* private static void updateGenesisConfigToLondon( | ||
final BesuNode minerNode, final boolean zeroBaseFeeEnabled) { | ||
final Optional<String> genesisConfig = | ||
minerNode.getGenesisConfigProvider().create(List.of(minerNode)); | ||
final ObjectNode genesisConfigNode = JsonUtil.objectNodeFromString(genesisConfig.orElseThrow()); | ||
final ObjectNode config = (ObjectNode) genesisConfigNode.get("config"); | ||
config.remove("berlinBlock"); | ||
config.put("londonBlock", 0); | ||
config.put("zeroBaseFee", zeroBaseFeeEnabled); | ||
minerNode.setGenesisConfig(genesisConfigNode.toString()); | ||
}*/ | ||
} |
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,2 @@ | ||
#!/bin/bash | ||
curl -v -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", "data":"0x6080604052336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005057600080fd5b5061021e806100606000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063445df0ac146100465780638da5cb5b14610064578063fdacd576146100ae575b600080fd5b61004e6100dc565b6040518082815260200191505060405180910390f35b61006c6100e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100da600480360360208110156100c457600080fd5b8101908080359060200190929190505050610107565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806101b76033913960400191505060405180910390fd5b806001819055505056fe546869732066756e6374696f6e206973207265737472696374656420746f2074686520636f6e74726163742773206f776e6572a265627a7a7231582007302f208a10686769509b529e1878bda1859883778d70dedd1844fe790c9bde64736f6c63430005100032","gas":"0x439cf","gasPrice":"0x0"},"latest"],"id":53}' http://127.0.0.1:8545 |