Skip to content

Commit

Permalink
build: Test against Go 1.19
Browse files Browse the repository at this point in the history
Fix linter warnings
  • Loading branch information
dajohi committed Aug 8, 2022
1 parent a7ad739 commit 3b3e9e0
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 28 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
name: Build and Test
on: [push, pull_request]
permissions:
contents: read

jobs:
build:
name: Go CI
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.17, 1.18]
go: [1.18, 1.19]
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a #v3.2.1
with:
go-version: ${{ matrix.go }}
- name: Check out source
uses: actions/checkout@v2
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
- name: Build
env:
GO111MODULE: "on"
run: go build ./...
- name: Test
env:
GO111MODULE: "on"
run: |
sh ./run_tests.sh
2 changes: 1 addition & 1 deletion dcrwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func run(ctx context.Context) error {
// initialized and this function returns.
defer func() {
// When panicing, do not cleanly unload the wallet (by closing
// the db). If a panic occured inside a bolt transaction, the
// the db). If a panic occurred inside a bolt transaction, the
// db mutex is still held and this causes a deadlock.
if r := recover(); r != nil {
panic(r)
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,7 @@ func (s *walletServer) UnlockAccount(ctx context.Context, req *pb.UnlockAccountR
}
return nil, err
}
err = s.wallet.UnlockAccount(ctx, req.AccountNumber, []byte(req.Passphrase))
err = s.wallet.UnlockAccount(ctx, req.AccountNumber, req.Passphrase)
if err != nil {
return nil, translateError(err)
}
Expand Down
4 changes: 2 additions & 2 deletions wallet/createtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1419,13 +1419,13 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op,
switch n := n.(type) {
case *dcrd.RPC:
dcp0010Active, err = deployments.DCP0010Active(ctx,
int32(tipHeight), w.chainParams, n)
tipHeight, w.chainParams, n)
if err != nil {
return nil, err
}
}
fee := txrules.StakePoolTicketFee(ticketPrice, ticketFee,
int32(tipHeight), feePrice, w.chainParams,
tipHeight, feePrice, w.chainParams,
dcp0010Active)

// Reserve outputs for number of buys.
Expand Down
5 changes: 1 addition & 4 deletions wallet/internal/bdb/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ func testNestedReadWriteBucket(tc *testContext, testBucket walletdb.ReadWriteBuc
defer func() {
tc.bucketDepth--
}()
if !testReadWriteBucketInterface(tc, testBucket) {
return false
}

return true
return testReadWriteBucketInterface(tc, testBucket)
}

// testReadWriteBucketInterface ensures the bucket interface is working
Expand Down
7 changes: 2 additions & 5 deletions wallet/udb/txdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ func expandOpCode(opCodeFlag byte) uint8 {
default:
// Original behavior. This cashes out to one of the OP_SS***
// opcode constants.
return uint8(((opCodeFlag >> 2) & 0x07) + 0xb9)
return ((opCodeFlag >> 2) & 0x07) + 0xb9
}
}

Expand Down Expand Up @@ -2156,11 +2156,8 @@ func (it *unspentTicketCommitsIterator) next() bool {
return false
}
it.amount, it.err = fetchRawTicketCommitmentAmount(v)
if it.err != nil {
return false
}

return true
return it.err == nil
}

func (it *unspentTicketCommitsIterator) close() {
Expand Down
2 changes: 1 addition & 1 deletion wallet/udb/vsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func SetVSPTicket(dbtx walletdb.ReadWriteTx, ticketHash *chainhash.Hash, record
// If the pubkey from the record in the request differs from the pubkey
// in the database that is saved for the host, update the pubkey in the
// db but keep the vsphost id intact.
if bytes.Compare(pubkey.PubKey, record.PubKey) != 0 {
if !bytes.Equal(pubkey.PubKey, record.PubKey) {
err = SetVSPPubKey(dbtx, []byte(record.Host), &VSPPubKey{
ID: pubkey.ID,
PubKey: record.PubKey,
Expand Down
3 changes: 1 addition & 2 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5604,8 +5604,7 @@ func (w *Wallet) GetVSPTicketsByFeeStatus(ctx context.Context, feeStatus int) ([

// SetPublished sets the informed hash as true or false.
func (w *Wallet) SetPublished(ctx context.Context, hash *chainhash.Hash, published bool) error {
var err error
err = walletdb.Update(ctx, w.db, func(dbtx walletdb.ReadWriteTx) error {
err := walletdb.Update(ctx, w.db, func(dbtx walletdb.ReadWriteTx) error {
hash := hash
err := w.txStore.SetPublished(dbtx, hash, published)
if err != nil {
Expand Down
7 changes: 2 additions & 5 deletions wallet/walletdb/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,8 @@ func testNestedReadWriteBucket(tc *testContext, bucket walletdb.ReadWriteBucket)
defer func() {
tc.bucketDepth--
}()
if !testReadWriteBucketInterface(tc, bucket) {
return false
}

return true
return testReadWriteBucketInterface(tc, bucket)
}

// testReadWriteBucketInterface ensures the read write bucket interface is
Expand Down Expand Up @@ -333,7 +330,7 @@ func testManualTxInterface(tc *testContext, bucketKey []byte) bool {
}
} else {
// The commit should succeed.
if err := tx.(walletdb.ReadWriteTx).Commit(); err != nil {
if err := tx.Commit(); err != nil {
tc.t.Errorf("Commit: unexpected error %v", err)
return false
}
Expand Down

0 comments on commit 3b3e9e0

Please sign in to comment.