Skip to content

Commit

Permalink
Restore to develop branch for some code (#138)
Browse files Browse the repository at this point in the history
* Add restore to develop branch for some code

* Skip android test
  • Loading branch information
devfans authored Oct 12, 2023
1 parent b101a5f commit 5fbe3fd
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 52 deletions.
1 change: 0 additions & 1 deletion consensus/hotstuff/core/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func (c *core) Stop() {
c.stopTimer()
c.isRunning = false
close(c.exit)

c.wg.Wait()
}

Expand Down
2 changes: 0 additions & 2 deletions contracts/native/governance/entrance.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func AssembleSystemTransactions(state *state.StateDB, height uint64) (types.Tran
if err != nil {
return nil, err
}

gas, err := core.IntrinsicGas(payload, nil, false, true, true)
if err != nil {
return nil, err
Expand All @@ -67,7 +66,6 @@ func AssembleSystemTransactions(state *state.StateDB, height uint64) (types.Tran
if err != nil {
return nil, err
}

gas, err := core.IntrinsicGas(payload, nil, false, true, true)
if err != nil {
return nil, err
Expand Down
38 changes: 0 additions & 38 deletions contracts/native/governance/node_manager/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,41 +108,3 @@ func StoreGenesisGlobalConfig(s *state.StateDB) error {
}
return nil
}

func StoreGenesisEpochForTest(s *state.StateDB, peers []common.Address, signers []common.Address,
blockPerEpoch *big.Int) (*EpochInfo, error) {
cache := (*state.CacheDB)(s)
epoch := &EpochInfo{
ID: StartEpochID,
Validators: peers,
Signers: signers,
Voters: signers,
Proposers: signers,
StartHeight: new(big.Int),
EndHeight: blockPerEpoch,
}

// store current epoch and epoch info
if err := setGenesisEpochInfo(cache, epoch); err != nil {
return nil, err
}
return epoch, nil
}

func StoreGenesisGlobalConfigForTest(s *state.StateDB, blockPerEpoch *big.Int) error {
cache := (*state.CacheDB)(s)
globalConfig := &GlobalConfig{
MaxCommissionChange: GenesisMaxCommissionChange,
MinInitialStake: GenesisMinInitialStake,
MinProposalStake: GenesisMinProposalStake,
BlockPerEpoch: blockPerEpoch,
ConsensusValidatorNum: GenesisConsensusValidatorNum,
VoterValidatorNum: GenesisVoterValidatorNum,
}

// store current epoch and epoch info
if err := setGenesisGlobalConfig(cache, globalConfig); err != nil {
return err
}
return nil
}
14 changes: 4 additions & 10 deletions contracts/native/governance/node_manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/contracts/native"
"github.com/ethereum/go-ethereum/contracts/native/contract"
. "github.com/ethereum/go-ethereum/contracts/native/go_abi/node_manager_abi"
"github.com/ethereum/go-ethereum/contracts/native/governance/community"
"github.com/ethereum/go-ethereum/contracts/native/utils"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -74,7 +72,7 @@ func TestCheckGenesis(t *testing.T) {

globalConfig, err := GetGlobalConfigImpl(contract)
assert.Nil(t, err)
assert.Equal(t, globalConfig.BlockPerEpoch, big.NewInt(400000))
assert.Equal(t, globalConfig.BlockPerEpoch, GenesisBlockPerEpoch)
assert.Equal(t, globalConfig.MaxCommissionChange, GenesisMaxCommissionChange)
assert.Equal(t, globalConfig.MinInitialStake, GenesisMinInitialStake)
assert.Equal(t, globalConfig.VoterValidatorNum, GenesisVoterValidatorNum)
Expand All @@ -98,7 +96,7 @@ func TestCheckGenesis(t *testing.T) {
globalConfig2 := new(GlobalConfig)
err = globalConfig2.Decode(ret)
assert.Nil(t, err)
assert.Equal(t, globalConfig2.BlockPerEpoch, big.NewInt(400000))
assert.Equal(t, globalConfig2.BlockPerEpoch, GenesisBlockPerEpoch)
assert.Equal(t, globalConfig2.MaxCommissionChange, GenesisMaxCommissionChange)
assert.Equal(t, globalConfig2.MinInitialStake, GenesisMinInitialStake)
assert.Equal(t, globalConfig2.VoterValidatorNum, GenesisVoterValidatorNum)
Expand Down Expand Up @@ -134,7 +132,7 @@ func TestCheckGenesis(t *testing.T) {

globalConfig, err = GetGlobalConfigFromDB(sdb)
assert.Nil(t, err)
assert.Equal(t, globalConfig.BlockPerEpoch, big.NewInt(400000))
assert.Equal(t, globalConfig.BlockPerEpoch, GenesisBlockPerEpoch)
}

func TestStake(t *testing.T) {
Expand Down Expand Up @@ -604,7 +602,6 @@ func TestDistribute(t *testing.T) {
// first add 1000 balance of node_manager contract to distribute
sdb.AddBalance(utils.NodeManagerContractAddress, new(big.Int).Mul(big.NewInt(1000), params.ZNT1))
// call endblock
sdb.SubBalance(utils.NodeManagerContractAddress, big.NewInt(800000000000000000))
param3 := new(EndBlockParam)
input, err = param3.Encode()
assert.Nil(t, err)
Expand Down Expand Up @@ -895,7 +892,6 @@ func TestDistribute(t *testing.T) {
// add 2000 balance of node_manager contract to distribute
sdb.AddBalance(utils.NodeManagerContractAddress, new(big.Int).Mul(big.NewInt(1000), params.ZNT1))
// call endblock
sdb.SubBalance(utils.NodeManagerContractAddress, big.NewInt(800000000000000000))
param9 := new(EndBlockParam)
input, err = param9.Encode()
assert.Nil(t, err)
Expand All @@ -905,7 +901,6 @@ func TestDistribute(t *testing.T) {

sdb.AddBalance(utils.NodeManagerContractAddress, new(big.Int).Mul(big.NewInt(1000), params.ZNT1))
// call endblock
sdb.SubBalance(utils.NodeManagerContractAddress, big.NewInt(800000000000000000))
param10 := new(EndBlockParam)
input, err = param10.Encode()
assert.Nil(t, err)
Expand Down Expand Up @@ -967,7 +962,7 @@ func TestDistribute(t *testing.T) {
b7, _ := new(big.Int).SetString("1000092307692307692280000", 10)
assert.Equal(t, sdb.GetBalance(stakeAddress), b6)
assert.Equal(t, sdb.GetBalance(stakeAddress2), b7)
assert.Equal(t, sdb.GetBalance(common.EmptyAddress), new(big.Int).SetUint64(600000000000180000))
assert.Equal(t, sdb.GetBalance(common.EmptyAddress), new(big.Int).SetUint64(180000))
_, found, err := getValidator(contractQuery, validatorsKey[0].ConsensusAddr)
assert.Nil(t, err)
assert.Equal(t, found, false)
Expand Down Expand Up @@ -1033,7 +1028,6 @@ func TestPerformance(t *testing.T) {
assert.Nil(t, err)

// call endblock
sdb.SubBalance(utils.NodeManagerContractAddress, big.NewInt(800000000000000000))
sdb.AddBalance(utils.NodeManagerContractAddress, new(big.Int).Mul(big.NewInt(10000000), params.ZNT1))
param := new(EndBlockParam)
input, err = param.Encode()
Expand Down
1 change: 0 additions & 1 deletion ethclient/ethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ func sendTransaction(ec *Client) error {
Gas: 22000,
GasPrice: big.NewInt(params.InitialBaseFee),
})

if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions mobile/android_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public class AndroidTest extends InstrumentationTestCase {
//
// This method has been adapted from golang.org/x/mobile/bind/java/seq_test.go/runTest
func TestAndroid(t *testing.T) {
t.Skip("skip android tests")
// Skip tests on Windows altogether
if runtime.GOOS == "windows" {
t.Skip("cannot test Android bindings on Windows, skipping")
Expand Down

0 comments on commit 5fbe3fd

Please sign in to comment.