Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go kosu/integration against testnet #226

Merged
merged 26 commits into from Aug 27, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4a8ae41
Integration Test Suite against testnet
gchaincl Aug 16, 2019
f127230
go-kosu: integration test cleanup
gchaincl Aug 20, 2019
a5f8518
go-kosu: update drone.yml
gchaincl Aug 20, 2019
6c85b72
test potential drone config for testnet
hrharder Aug 21, 2019
3ed7a78
migrate to second contract system server
hrharder Aug 21, 2019
abb2e0d
fixing dronefile syntax
hrharder Aug 21, 2019
9350ae7
fixing node step names
hrharder Aug 21, 2019
1b6573d
Merge branch 'master' into go-kosu/integration-against-testnet
hrharder Aug 21, 2019
867bfeb
add verbose flag to GOTEST_FLAGS
hrharder Aug 21, 2019
7366970
add required environment variable for int. tests
hrharder Aug 21, 2019
5008ef4
use alternate go-kosu geth image for web3
hrharder Aug 21, 2019
115968b
fix export command
hrharder Aug 22, 2019
7b8ffc5
update hostnames for persistent peers
hrharder Aug 22, 2019
92fb51d
Fully move .drone to jsonnet definitions
gchaincl Aug 22, 2019
5f118e0
readd autogenerated .drone.yml
gchaincl Aug 22, 2019
5012b35
change "_" to "-"
hrharder Aug 22, 2019
cd6c221
Merge branch 'master' into go-kosu/integration-against-testnet
gchaincl Aug 22, 2019
4b00670
go-kosu: witness ethereum tests uses WS endpoint
gchaincl Aug 22, 2019
ac640ce
Merge branch 'master' into go-kosu/integration-against-testnet
hrharder Aug 22, 2019
1847687
Merge branch 'master' into go-kosu/integration-against-testnet
hrharder Aug 23, 2019
e5d0770
go-kosu: disable race detector on tests
gchaincl Aug 26, 2019
cb3572e
Merge branch 'master' into go-kosu/integration-against-testnet
gchaincl Aug 26, 2019
6667a5c
Extending time out for more taxed CI host.
Freydal Aug 26, 2019
bca08d7
Updating image name.
Freydal Aug 26, 2019
8e6a185
Merge branch 'master' into go-kosu/integration-against-testnet
gchaincl Aug 27, 2019
3f6c1cd
Merge branch 'master' into go-kosu/integration-against-testnet
gchaincl Aug 27, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Integration Test Suite against testnet

  • Loading branch information
gchaincl committed Aug 16, 2019
commit 4a8ae412a7bd4bc87a18b8746bf2dab1760db14e
@@ -71,7 +71,7 @@ func (app *App) NewClient() (*Client, error) {
return nil, err
}

return NewHTTPClient(url, key), nil
return NewHTTPClient(url, key)
}

// Query queries the application state using the store.Query method
@@ -301,5 +301,5 @@ func (app *App) DeliverTx(req []byte) abci.ResponseDeliverTx {
fmt.Printf("Unknown Tx: %t", tx.GetData())
}

return abci.ResponseDeliverTx{Code: 1, Info: "Unknown Transaction type"}
return abci.ResponseDeliverTx{Code: 1, Log: "Unknown Transaction type"}
}
@@ -32,9 +32,13 @@ func NewClient(c client.Client, key []byte) *Client {
}

// NewHTTPClient calls NewClient using a HTTPClient as ABCClient
func NewHTTPClient(addr string, key []byte) *Client {
func NewHTTPClient(addr string, key []byte) (*Client, error) {
c := client.NewHTTP(addr, "/websocket")
return NewClient(c, key)
if err := c.Start(); err != nil {
return nil, err
}

return NewClient(c, key), nil
}

// BroadcastTxAsync will return right away without waiting to hear if the transaction is even valid
@@ -90,24 +94,13 @@ func (c *Client) Subscribe(ctx context.Context, q string) (<-chan rpctypes.Resul
return nil, nil, err
}

// Start WS if not yet
if httpC, ok := c.Client.(*client.HTTP); ok {
if !httpC.IsRunning() {
if err := httpC.Start(); err != nil {
return nil, nil, err
}
}
}

ch, err := c.Client.Subscribe(ctx, "kosu", q)
if err != nil {
return nil, nil, err
}

closer := func() {
if httpC, ok := c.Client.(*client.HTTP); ok {
_ = httpC.Stop()
}
_ = c.Client.Unsubscribe(ctx, "kosu", q)
}

return ch, closer, nil
@@ -138,6 +131,27 @@ func (c *Client) QueryConsensusParams() (*types.ConsensusParams, error) {
return &pb, nil
}

// QueryLastEvent performs a ABCI Query to "/lastevent".
// `lastevent` keeps track of the last block height recorded from the Ethereum chain
func (c *Client) QueryLastEvent() (uint64, error) {
out, err := c.ABCIQuery("/chain/key", []byte("lastevent"))
if err != nil {
return 0, err
}
res := out.Response

if res.IsErr() {
return 0, errors.New(res.GetLog())
}

if len(res.Value) == 0 {
return 0, nil
}

buf := proto.NewBuffer(res.Value)
return buf.DecodeFixed64()
}

// QueryPoster performs a ABCI Query to "/posters/<addr>"
func (c *Client) QueryPoster(addr string) (*types.Poster, error) {
var pb types.Poster
@@ -33,8 +33,8 @@ func (app *App) deliverWitnessTx(tx *types.TransactionWitness, nodeID []byte) ab
}

func (app *App) pruneWitnessTxs(block uint64) {
params := app.store.ConsensusParams()
fn := func(tx *types.TransactionWitness) {
params := app.store.ConsensusParams()
if block-tx.Block >= params.BlocksBeforePruning {
app.log.Debug("Pruning tx", "id", hex.EncodeToString(tx.Id))
app.store.DeleteWitnessTx(tx.Id)
@@ -15,7 +15,7 @@ import (
)

func main() {
var client abci.Client
var client *abci.Client

rootCmd := &cobra.Command{
Use: "kosu-cli",
@@ -45,11 +45,11 @@ func main() {
addr := cmd.Flag("abci").Value.String()

// update the client
client = *abci.NewHTTPClient(addr, key)
return nil
client, err = abci.NewHTTPClient(addr, key)
return err
}

abci := cli.New(&client)
abci := cli.New(client)

tx := &cobra.Command{
Use: "tx",
@@ -42,9 +42,12 @@ func newDB(dir string, debug bool) (db.DB, error) {
}

func startWitness(ctx context.Context, ethAddr string, nodeAddr string, key []byte, logger log.Logger) error {
client := abci.NewHTTPClient(nodeAddr, key)
p, err := witness.NewEthereumProvider(ethAddr)
client, err := abci.NewHTTPClient(nodeAddr, key)
if err != nil {
return nil
}

p, err := witness.NewEthereumProvider(ethAddr)
if err != nil {
return err
}
@@ -49,8 +49,11 @@ func NewCommand() *cobra.Command {

return nil
},
Run: func(cmd *cobra.Command, args []string) {
client := abci.NewHTTPClient(url, key)
RunE: func(cmd *cobra.Command, args []string) error {
client, err := abci.NewHTTPClient(url, key)
if err != nil {
return err
}
srv := NewServer(client)

wg := sync.WaitGroup{}
@@ -74,6 +77,7 @@ func NewCommand() *cobra.Command {
}()
}
wg.Wait()
return nil
},
}

@@ -28,13 +28,8 @@ func newServerClient(t *testing.T) (*abci.App, *rpc.Client, func()) {
}

func TestRPCLatestHeight(t *testing.T) {
_, closer := tests.StartServer(t, db.NewMemDB())
_, client, closer := newServerClient(t)
defer closer()
client := rpc.DialInProc(
NewServer(
abci.NewHTTPClient("http://localhost:26657", nil),
),
)

var latest uint64
// Get the initial (prior the first block is mined)
@@ -22,7 +22,7 @@ db_backend = "leveldb"
db_dir = "data"

# Output level for logging, including package level options
log_level = "app:info,*:error"
log_level = "app:debug,*:error"

# Output format: 'plain' (colored text) or 'json'
log_format = "plain"
@@ -43,7 +43,8 @@
"app_state": {
"ConsensusParams": {
"PeriodLimit": 100000,
"PeriodLength": 10
"PeriodLength": 10,
"BlocksBeforePruning": 10
}
}
}
@@ -43,7 +43,8 @@
"app_state": {
"ConsensusParams": {
"PeriodLimit": 100000,
"PeriodLength": 10
"PeriodLength": 10,
"BlocksBeforePruning": 10
}
}
}
@@ -43,7 +43,8 @@
"app_state": {
"ConsensusParams": {
"PeriodLimit": 100000,
"PeriodLength": 10
"PeriodLength": 10,
"BlocksBeforePruning": 10
}
}
}
@@ -43,7 +43,8 @@
"app_state": {
"ConsensusParams": {
"PeriodLimit": 100000,
"PeriodLength": 10
"PeriodLength": 10,
"BlocksBeforePruning": 10
}
}
}
@@ -0,0 +1,25 @@
package tests

import (
"math/rand"
"os"
"testing"
)

func envOrSkip(t *testing.T, env string) string {
v := os.Getenv(env)
if v == "" {
t.Skipf("Integration test suite requires '%s' to be exported", env)
}
return v
}

func randomHex(size int) string {
var alphabet = []rune("abcdefABCDEF0123456789")

b := make([]rune, size)
for i := range b {
b[i] = alphabet[rand.Intn(len(alphabet))]
}
return string(b)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.