github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/tests/web3/web3test/web3test.go (about)

     1  package web3test
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/hyperledger/burrow/crypto"
     9  	"github.com/hyperledger/burrow/rpc/lib/jsonrpc"
    10  	"github.com/stretchr/testify/require"
    11  	"github.com/tmthrgd/go-hex"
    12  )
    13  
    14  const ganacheRemote = "http://127.0.0.1:8545"
    15  
    16  // Configured in the "ganache" yarn script in vent/test/eth/package.json
    17  var ganachePrivateKey = hex.MustDecodeString("cfad15e9e8f24b5b5608cac150293fe971d23cd9168206b231c859b7974d4295")
    18  
    19  // Set INFURA_SECRET to the basic auth password to use infura remote
    20  var infuraRemote = fmt.Sprintf("https://:%s@ropsten.infura.io/v3/7ed3059377654803a190fa44560d528f",
    21  	os.Getenv("INFURA_SECRET"))
    22  
    23  // Toggle below to switch to an infura test
    24  var remote = ganacheRemote
    25  
    26  //var remote = infuraRemote
    27  
    28  var client = jsonrpc.NewClient(remote)
    29  
    30  func GetChainRemote() string {
    31  	return remote
    32  }
    33  
    34  func GetChainRPCClient() *jsonrpc.Client {
    35  	return client
    36  }
    37  
    38  func GetPrivateKey(t testing.TB) *crypto.PrivateKey {
    39  	if remote == ganacheRemote {
    40  		pk, err := crypto.PrivateKeyFromRawBytes(ganachePrivateKey, crypto.CurveTypeSecp256k1)
    41  		require.NoError(t, err)
    42  		return &pk
    43  	}
    44  	// This account (5DA093B66C2D373E4CBB6081312BE5DFCFF66189) had some test ether on Ropsten at some point:
    45  	// https://ropsten.etherscan.io/address/0x5DA093B66C2D373E4CBB6081312BE5DFCFF66189
    46  	// https://faucet.dimensions.network/ seems to be less trigger happy on banning you to top up eth supply
    47  	pk := crypto.PrivateKeyFromSecret("fooooo", crypto.CurveTypeSecp256k1)
    48  	fmt.Println(pk.GetAddress())
    49  	return &pk
    50  }