mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 00:43:46 +00:00
Test isValidatorAction 🚧
This commit is contained in:
parent
27fc66ef24
commit
a3e01638a4
2 changed files with 58 additions and 0 deletions
|
|
@ -1233,6 +1233,7 @@ func (c *Bor) isValidatorAction(chain consensus.ChainReader, from common.Address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @todo only either of proposeState and proposeSpan should pass this check
|
// @todo only either of proposeState and proposeSpan should pass this check
|
||||||
|
fmt.Println("tx.Data", tx.Data())
|
||||||
return _isValidatorAction
|
return _isValidatorAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
57
consensus/bor/bor_test.go
Normal file
57
consensus/bor/bor_test.go
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
package bor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/big"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/maticnetwork/bor/common"
|
||||||
|
"github.com/maticnetwork/bor/core"
|
||||||
|
"github.com/maticnetwork/bor/core/rawdb"
|
||||||
|
"github.com/maticnetwork/bor/core/types"
|
||||||
|
"github.com/maticnetwork/bor/core/vm"
|
||||||
|
"github.com/maticnetwork/bor/crypto"
|
||||||
|
"github.com/maticnetwork/bor/internal/ethapi"
|
||||||
|
"github.com/maticnetwork/bor/params"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MockEthAPI struct{}
|
||||||
|
|
||||||
|
// func (ethapi *MockEthAPI) call()
|
||||||
|
|
||||||
|
func TestIsValidatorAction(t *testing.T) {
|
||||||
|
var (
|
||||||
|
db = rawdb.NewMemoryDatabase()
|
||||||
|
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
|
addr = crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
// bor = New(¶ms.ChainConfig{}, db, ðapi.PublicBlockChainAPI{})
|
||||||
|
// signer = new(types.HomesteadSigner)
|
||||||
|
)
|
||||||
|
genspec := &core.Genesis{
|
||||||
|
ExtraData: make([]byte, extraVanity+common.AddressLength+extraSeal),
|
||||||
|
Alloc: map[common.Address]core.GenesisAccount{
|
||||||
|
addr: {Balance: big.NewInt(1)},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
copy(genspec.ExtraData[extraVanity:], addr[:])
|
||||||
|
genspec.MustCommit(db)
|
||||||
|
// genesis := genspec.MustCommit(db)
|
||||||
|
config := ¶ms.ChainConfig{
|
||||||
|
Bor: ¶ms.BorConfig{
|
||||||
|
ValidatorContract: "0x0000000000000000000000000000000000001000",
|
||||||
|
StateReceiverContract: "0x0000000000000000000000000000000000001001",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
bor := New(config, db, ðapi.PublicBlockChainAPI{})
|
||||||
|
chain, err := core.NewBlockChain(db, nil, config, bor, vm.Config{}, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tx := types.NewTransaction(
|
||||||
|
0,
|
||||||
|
addr, // to - Just a place holder
|
||||||
|
big.NewInt(0), 0 /* fix gas limit */, big.NewInt(0),
|
||||||
|
nil, // data
|
||||||
|
)
|
||||||
|
bor.isValidatorAction(chain, addr, tx)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue