package multisend

import (
	sync "sync"
	"testing"
)

func TestTransactor(t *testing.T) {

	//go StartProduceTx("127.0.0.1:6379", "redis20220217")

	//for {
	//	if len(originalTxsHashQueue) >= 10 {
	//		break
	//	}

	//	t.Logf("waiting for produce original tx, len(originalTxsHashQueue):%d \n", len(originalTxsHashQueue))
	//	time.Sleep(1 * time.Second)
	//}
	cfg := Config{
		Rate:          1,
		Count:         3000,
		Connections:   1,
		Time:          1000000,
		SendPeriod:    3,
		ClientFactory: "ethclient",
	}
	//wss://ws-mainnet-node.huobichain.com
	//transactor, err := NewTransactor("wss://ws-mainnet-node.huobichain.com", &cfg)
	transactor, err := NewTransactor("ws://13.40.31.153:8546", &cfg)

	if err != nil {
		t.Error(err)
	}
	//transactor.sendTransactions()
	//transactor.sendLoop()
	transactor.Start()

	wg := sync.WaitGroup{}

	wg.Add(1)

	go func() {
		defer wg.Done()
		if err := ProduceOriginalTx(); err != nil {
			t.Error(err.Error())
			return
		}

	}()

	Start("127.0.0.1:6379", "redis20220217")

}
