Skip to content

dexcctl: add simnet configuration script#587

Merged
chappjc merged 2 commits into
decred:masterfrom
buck54321:simnet-script
Aug 11, 2020
Merged

dexcctl: add simnet configuration script#587
chappjc merged 2 commits into
decred:masterfrom
buck54321:simnet-script

Conversation

@buck54321
Copy link
Copy Markdown
Member

A script to set up simnet wallets and register with the DEX. Adds command line passwords to dexcctl.

The Decred simnet password is changed to "abc" to be consistent with the BTC harness.

Adds command line passwords to dexcctl.

The Decred simnet password is changed to 'abc' to be consistent
with the BTC harness.
ALPHA_WALLET_SEED="b280922d2cffda44648346412c5ec97f429938105003730414f10b01e1402eac"
BETA_WALLET_SEED="aabbcaabbcaabbcaabbcaabbcaabbcaabbcaabbcaabbcaabbcaabbcaabbcaabbc"
WALLET_PASS=123
WALLET_PASS=abc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really handy.

One thing I had shashed for harness.sh was this:

@@ -103,6 +103,11 @@ chmod +x "${NODES_ROOT}/harness-ctl/reorg"
 # Shutdown script
 cat > "${NODES_ROOT}/harness-ctl/quit" <<EOF
 #!/bin/sh
+tmux send-keys -t $SESSION:3 C-c
+tmux send-keys -t $SESSION:4 C-c
+tmux send-keys -t $SESSION:5 C-c
+tmux send-keys -t $SESSION:6 C-c
+sleep 0.2
 tmux send-keys -t $SESSION:1 C-c
 tmux send-keys -t $SESSION:2 C-c
 tmux wait-for alphadcr

I didn't understand how we were getting away with only interrupting the alpha and beta dcrd procs, but not the dcrwallets.


const (
walletPassword = "123"
walletPassword = "abc"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing I has stashed for simnet_test.go (I think we were both looking into these) was:

--- a/client/asset/dcr/simnet_test.go
+++ b/client/asset/dcr/simnet_test.go
@@ -58,6 +58,7 @@ func mineAlpha() error {
 }
 
 func tBackend(t *testing.T, name string, blkFunc func(string, error)) (*ExchangeWallet, *dex.ConnectionMaster) {
+       t.Helper()
        user, err := user.Current()
        if err != nil {
                t.Fatalf("error getting current user: %v", err)
@@ -93,6 +94,7 @@ type testRig struct {
 }
 
 func newTestRig(t *testing.T, blkFunc func(string, error)) *testRig {
+       t.Helper()
        rig := &testRig{
                backends:          make(map[string]*ExchangeWallet),
                connectionMasters: make(map[string]*dex.ConnectionMaster, 3),
@@ -109,6 +111,7 @@ func (rig *testRig) beta() *ExchangeWallet {
        return rig.backends["beta"]
 }
 func (rig *testRig) close(t *testing.T) {
+       t.Helper()
        for name, cm := range rig.connectionMasters {
                closed := make(chan struct{})
                go func() {
@@ -247,6 +250,7 @@ func TestWallet(t *testing.T) {
 
        confCoin := receipts[0].Coin()
        checkConfs := func(n uint32) {
+               t.Helper()
                confs, err := rig.beta().Confirmations(confCoin.ID())
                if err != nil {
                        t.Fatalf("error getting %d confs: %v", n, err)

Wanna sneak those in too?

# calling this script.
set -e
echo initializing
./dexcctl -p abc init
Copy link
Copy Markdown
Member

@chappjc chappjc Aug 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently I've been running dexc with --rpcaddr=localhost:6757 --webaddr=localhost:6758 for simnet, which goes back to #557. This makes me realize the network dependent ports would need to be coordinated with dexcctl. That is, do you think it would make sense to have a --testnet/--simnet flag for dexcctl that switches these ports automatically? (but not in this PR ofc)

Copy link
Copy Markdown
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff. Just my other comments with diffs from my stash if you want to integrate those. Your call.

echo mining fee confirmation blocks
tmux send-keys -t dcr-harness:0 "./mine-alpha 1" C-m
sleep 2
tmux send-keys -t dcr-harness:0 "./mine-alpha 1" C-m No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 seconds to register and authenticate!

$    time ./simnet-setup.sh 
initializing
app initialized
configuring Decred wallet
dcr wallet created and unlocked
configuring Bitcoin wallet
btc wallet created and unlocked
registering with DEX
{
  "feeID": "ec77729e4dec81bfb1e1f9212f89e2c336d8b353d4cca5764cb0c1f56b7a0233:0",
  "reqConfirms": 1
}
mining fee confirmation blocks

real	0m5.346s
user	0m1.931s
sys	0m0.108s

@chappjc chappjc requested a review from JoeGruffins August 7, 2020 18:49
Copy link
Copy Markdown
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well.

Comment thread client/cmd/dexcctl/simnet-setup.sh Outdated
echo configuring Bitcoin wallet
./dexcctl -p abc -p abc newwallet 0 ~/dextest/btc/harness-ctl/alpha.conf '{"walletname":"gamma"}'
echo registering with DEX
./dexcctl -p abc register 127.0.0.1:7232 100000000 ~/.dcrdex/rpc.cert
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simnet test dcrdex is on port 17273 and certificate is at ~/dextest/dcrdex/rpc.cert

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about the cert, but dcrdex doesn't change the port, at least not automatically, depending on net. Same with dexc BTW, and I'd welcome resolutions to that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simnet test dcrdex is on port 17273 and certificate is at ~/dextest/dcrdex/rpc.cert

Good point. I've only been using the dcrdex simnet server for the core -tags harness test, but I'll start using it for manual testing too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I haven't been using any of the harnesses when not specifically testing them because I hate having a folder called "dextest" in my home, but I guess I'll just have to get over it because it's not worth keeping up with changes.

Copy link
Copy Markdown
Member

@chappjc chappjc Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a problem with using that harness for general testing is the 1min/30sec lock times (the script builds dcrdex with special flags). I don't think we should encourage using the harness for general testing, especially interactive, unless we make the dex/testing/dcrdex/harness.sh lock times longer by default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, we should revert this change to client/cmd/dexcctl/simnet-setup.sh or we should modify dex/testing/dcrdex/harness.sh with a flag to change the lock times only if requested.

@chappjc chappjc merged commit 6b1ab16 into decred:master Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants