mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
add validation to randomize smc
This commit is contained in:
parent
15c5f76c39
commit
b53a7a111a
3 changed files with 20 additions and 6 deletions
|
|
@ -222,7 +222,7 @@ func (w *wizard) makeGenesis() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Randomize Smart Contract Code
|
// Randomize Smart Contract Code
|
||||||
randomizeAddress, _, err := randomizeContract.DeployRandomize(transactOpts, contractBackend, big.NewInt(90))
|
randomizeAddress, _, err := randomizeContract.DeployRandomize(transactOpts, contractBackend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Can't deploy root registry")
|
fmt.Println("Can't deploy root registry")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,24 @@
|
||||||
|
// Copyright (c) 2018 Xinfin
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package randomize
|
package randomize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/contracts/randomize/contract"
|
"github.com/ethereum/go-ethereum/contracts/randomize/contract"
|
||||||
"math/big"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Randomize struct {
|
type Randomize struct {
|
||||||
|
|
@ -27,8 +41,8 @@ func NewRandomize(transactOpts *bind.TransactOpts, contractAddr common.Address,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeployRandomize(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend, randomNumber *big.Int) (common.Address, *Randomize, error) {
|
func DeployRandomize(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *Randomize, error) {
|
||||||
randomizeAddr, _, _, err := contract.DeployXDCRandomize(transactOpts, contractBackend, randomNumber)
|
randomizeAddr, _, _, err := contract.DeployXDCRandomize(transactOpts, contractBackend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return randomizeAddr, nil, err
|
return randomizeAddr, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func TestRandomize(t *testing.T) {
|
||||||
transactOpts := bind.NewKeyedTransactor(key)
|
transactOpts := bind.NewKeyedTransactor(key)
|
||||||
transactOpts.GasLimit = 1000000
|
transactOpts.GasLimit = 1000000
|
||||||
|
|
||||||
randomizeAddress, randomize, err := DeployRandomize(transactOpts, contractBackend, big.NewInt(2))
|
randomizeAddress, randomize, err := DeployRandomize(transactOpts, contractBackend)
|
||||||
t.Log("contract address", randomizeAddress.String())
|
t.Log("contract address", randomizeAddress.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't deploy root registry: %v", err)
|
t.Fatalf("can't deploy root registry: %v", err)
|
||||||
|
|
@ -64,7 +64,7 @@ func TestSendTxRandomizeSecretAndOpening(t *testing.T) {
|
||||||
transactOpts := bind.NewKeyedTransactor(acc1Key)
|
transactOpts := bind.NewKeyedTransactor(acc1Key)
|
||||||
transactOpts.GasLimit = 4200000
|
transactOpts.GasLimit = 4200000
|
||||||
epocNumber := uint64(900)
|
epocNumber := uint64(900)
|
||||||
randomizeAddr, randomizeContract, err := DeployRandomize(transactOpts, backend, new(big.Int).SetInt64(0))
|
randomizeAddr, randomizeContract, err := DeployRandomize(transactOpts, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Can't deploy randomize SC: %v", err)
|
t.Fatalf("Can't deploy randomize SC: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue