From 4af7e5e327a55b4308c4604708d7e0eb7ba59411 Mon Sep 17 00:00:00 2001 From: elnosh Date: Thu, 23 May 2024 13:55:06 -0500 Subject: [PATCH] gh actions setup --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ crypto/bdhke_test.go | 6 ++---- go.mod | 2 +- go.sum | 10 ++++++++-- testutils/utils.go | 17 ++++++++++++++++- 5 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..84e9fa4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22.2 + + - name: Go Fmt + run: go fmt ./... + + - name: Go Vet + run: go vet ./... + + - name: Tests + run: go test -v ./... + + - name: Integration Tests + run: go test -v --tags=integration ./mint + - run: go test -v --tags=integration ./wallet diff --git a/crypto/bdhke_test.go b/crypto/bdhke_test.go index 3f1b3dd..d9bfa11 100644 --- a/crypto/bdhke_test.go +++ b/crypto/bdhke_test.go @@ -38,7 +38,6 @@ func TestHashToCurve(t *testing.T) { } } - func TestBlindMessage(t *testing.T) { tests := []struct { secret string @@ -170,8 +169,7 @@ func TestVerify(t *testing.T) { } } - -// Tests for deprecated HashToCurve +// Tests for deprecated HashToCurve func TestHashToCurveDeprecated(t *testing.T) { tests := []struct { message string @@ -228,4 +226,4 @@ func TestBlindMessageDeprecated(t *testing.T) { t.Errorf("expected '%v' but got '%v' instead\n", test.expected, B_Hex) } } -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index 50807ee..1b362f7 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.3.3 github.com/btcsuite/btcd/btcutil v1.1.5 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 - github.com/elnosh/btc-docker-test v0.0.0-20240516172412-66d8d1782e3c + github.com/elnosh/btc-docker-test v0.0.0-20240523211148-14c62fc20775 github.com/gorilla/mux v1.8.0 github.com/joho/godotenv v1.5.1 github.com/lightningnetwork/lnd v0.17.4-beta.rc1 diff --git a/go.sum b/go.sum index cd3de8f..25bb9aa 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,14 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/elnosh/btc-docker-test v0.0.0-20240516172412-66d8d1782e3c h1:LXQMak0LIMl9CP+0bo3egNpKyM48RysgQgsemCuJ+d0= -github.com/elnosh/btc-docker-test v0.0.0-20240516172412-66d8d1782e3c/go.mod h1:5GQRdR6yg5zIuTV8ZM6bPsp1R10d7XJNQHys/knsXsg= +github.com/elnosh/btc-docker-test v0.0.0-20240523201318-f115b8e72433 h1:GpiTYDCIhyFtYZB1VzjXA9LQjnXzDw0GTbzEUmaDF6o= +github.com/elnosh/btc-docker-test v0.0.0-20240523201318-f115b8e72433/go.mod h1:5GQRdR6yg5zIuTV8ZM6bPsp1R10d7XJNQHys/knsXsg= +github.com/elnosh/btc-docker-test v0.0.0-20240523204259-9b1fd7f92fc8 h1:87maGK4TDtlOnzAYx/Tx3RMITm89ylT8RrDeQixS8/U= +github.com/elnosh/btc-docker-test v0.0.0-20240523204259-9b1fd7f92fc8/go.mod h1:5GQRdR6yg5zIuTV8ZM6bPsp1R10d7XJNQHys/knsXsg= +github.com/elnosh/btc-docker-test v0.0.0-20240523205238-59b9e129b428 h1:fzUFUN+r8oQ/Iy2ZSrqV46zI1gCoZsfLXrF1nsU9TDI= +github.com/elnosh/btc-docker-test v0.0.0-20240523205238-59b9e129b428/go.mod h1:5GQRdR6yg5zIuTV8ZM6bPsp1R10d7XJNQHys/knsXsg= +github.com/elnosh/btc-docker-test v0.0.0-20240523211148-14c62fc20775 h1:d49YXlSBmcVjc6ZeUfhvQjK+2aNQ2vKBlz9w6TRzphg= +github.com/elnosh/btc-docker-test v0.0.0-20240523211148-14c62fc20775/go.mod h1:5GQRdR6yg5zIuTV8ZM6bPsp1R10d7XJNQHys/knsXsg= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= diff --git a/testutils/utils.go b/testutils/utils.go index d7f88a7..28795b3 100644 --- a/testutils/utils.go +++ b/testutils/utils.go @@ -162,11 +162,26 @@ func mintConfig(lnd *btcdocker.Lnd, key, port, dbpath string) (*mint.Config, err DBPath: dbpath, } nodeDir := lnd.LndDir + currentDir, err := os.Getwd() + if err != nil { + return nil, fmt.Errorf("error getting current dir: %v", err) + } + + macaroonPath := filepath.Join(currentDir, "/admin.macaroon") + file, err := os.Create(macaroonPath) + if err != nil { + return nil, fmt.Errorf("error creating macaroon file: %v", err) + } + + _, err = file.Write(lnd.AdminMacaroon) + if err != nil { + return nil, fmt.Errorf("error writing to macaroon file: %v", err) + } os.Setenv("LIGHTNING_BACKEND", "Lnd") os.Setenv("LND_REST_HOST", "https://"+lnd.Host+":"+lnd.RestPort) os.Setenv("LND_CERT_PATH", filepath.Join(nodeDir, "/tls.cert")) - os.Setenv("LND_MACAROON_PATH", filepath.Join(nodeDir, "/data/chain/bitcoin/regtest/admin.macaroon")) + os.Setenv("LND_MACAROON_PATH", macaroonPath) return mintConfig, nil }