diff --git a/client/core/account.go b/client/core/account.go index c604c95c9b..167908b13f 100644 --- a/client/core/account.go +++ b/client/core/account.go @@ -62,6 +62,10 @@ func (c *Core) ToggleAccountStatus(pw []byte, addr string, disable bool) error { return newError(unknownDEXErr, "error retrieving dex conn: %w", err) } + if dc.acct.isDisabled() == disable { + return nil // no-op + } + if disable { // Check active orders or bonds. if dc.hasActiveOrders() { diff --git a/client/core/account_test.go b/client/core/account_test.go index 09a6aa1139..73e8ebeb70 100644 --- a/client/core/account_test.go +++ b/client/core/account_test.go @@ -64,7 +64,6 @@ func TestToggleAccountStatus(t *testing.T) { {}: {metaData: &db.OrderMetaData{Status: order.OrderStatusBooked}}, } - // TODO: Add test case for enable dex account tests := []struct { name, host string recryptErr, acctErr, disableAcctErr error @@ -72,9 +71,13 @@ func TestToggleAccountStatus(t *testing.T) { activeTrades map[order.OrderID]*trackedTrade errCode int }{{ - name: "ok", + name: "ok: disable account", host: tDexHost, wantDisable: true, + }, { + name: "ok: enable account", + host: tDexHost, + wantDisable: false, }, { name: "password error", host: tDexHost, @@ -143,8 +146,8 @@ func TestToggleAccountStatus(t *testing.T) { t.Fatalf("unexpected error for test %v: %v", test.name, err) } if test.wantDisable { - if _, found := tCore.conns[test.host]; found { - t.Fatal("found disabled account dex connection") + if dc, found := tCore.conns[test.host]; found && !dc.acct.isDisabled() { + t.Fatal("expected disabled account dex connection") } if rig.db.disabledHost == nil { t.Fatal("expected a disable dex server host") @@ -153,6 +156,10 @@ func TestToggleAccountStatus(t *testing.T) { t.Fatalf("expected db account to match test host, want: %v"+ " got: %v", test.host, *rig.db.disabledHost) } + } else { + if dc, found := tCore.conns[test.host]; found && dc.acct.isDisabled() { + t.Fatal("expected enabled dex account") + } } } } diff --git a/client/webserver/site/src/html/dexsettings.tmpl b/client/webserver/site/src/html/dexsettings.tmpl index 36eb61640f..acb38bc92d 100644 --- a/client/webserver/site/src/html/dexsettings.tmpl +++ b/client/webserver/site/src/html/dexsettings.tmpl @@ -152,4 +152,4 @@ {{template "bottom"}} -{{end}} \ No newline at end of file +{{end}}