Skip to content

Commit

Permalink
minor repo cleanup (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni authored Sep 1, 2024
1 parent a4f5d04 commit a51269f
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 63 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ updates:
open-pull-requests-limit: 10
labels:
- T:dependencies
target-branch: dev
35 changes: 35 additions & 0 deletions .github/workflows/checks.golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Generated by @zondax/cli
#
name: Checks

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Build
run: |
make build
- name: ModTidy check
run: make check-modtidy
- name: Lint check
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make install_lint
make lint
- name: Run tests
run: |
make test
14 changes: 12 additions & 2 deletions .github/workflows/test.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Test

on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- master
- main
pull_request:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:

Expand All @@ -13,7 +20,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.18'
go-version: '1.21'
- name: Build
run: |
go build
- name: test & coverage report creation
run: |
go test common.go -mod=readonly -timeout 5m -short -race -coverprofile=coverage.txt -covermode=atomic
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ cmake-build-debug/
\.idea/workspace\.xml
\.idea/
vendor/

coverage.txt
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018 - 2022 ZondaX AG
Copyright Zondax AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Generated by @zondax/cli
#
-include Makefile.settings.mk

# Get all directories under cmd
CMDS=$(shell find cmd -type d)

# Strip cmd/ from directory names and generate output binary names
BINS=$(subst cmd/,output/,$(CMDS))

default: build

build:
@go build

mod-tidy:
@go mod tidy

mod-clean:
go clean -modcache

mod-update: mod-clean
@go get -u ./...
@go mod tidy

generate: mod-tidy
go generate ./internal/...

version: build
./output/$(APP_NAME) version

clean:
go clean

gitclean:
git clean -xfd
git submodule foreach --recursive git clean -xfd

install_lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin latest

check-modtidy:
@go mod tidy
git diff --exit-code -- go.mod go.sum

lint:
golangci-lint --version
golangci-lint run

test:
@go test common.go -mod=readonly -timeout 5m -short -race -coverprofile=coverage.txt -covermode=atomic
@go test common.go -mod=readonly -timeout 5m
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# ledger-cosmos-go

[![Test](https://github.com/cosmos/ledger-cosmos-go/actions/workflows/test.yml/badge.svg)](https://github.com/cosmos/ledger-cosmos-go/actions/workflows/test.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GithubActions](https://github.com/zondax/ledger-go/actions/workflows/main.yml/badge.svg)](https://github.com/Zondax/ledger-go/blob/main/.github/workflows/main.yml)
[![Build status](https://ci.appveyor.com/api/projects/status/ovpfx35t289n3403?svg=true)](https://ci.appveyor.com/project/cosmos/ledger-cosmos-go)

This project is work in progress. Some aspects are subject to change.

# Get source
Apart from cloning, be sure you install dep dependency management tool
https://github.com/golang/dep
25 changes: 0 additions & 25 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
* (c) Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion common_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2018 - 2022 Zondax AG
* (c) Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions user_app.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
* (c) Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -330,7 +330,7 @@ func (ledger *LedgerCosmos) getAddressPubKeySECP256K1(bip32Path []uint32, hrp st
}

pubkey = response[0:33]
addr = string(response[33:len(response)])
addr = string(response[33:])

return pubkey, addr, err
}
26 changes: 13 additions & 13 deletions user_app_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
* (c) Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ import (
func Test_UserFindLedger(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}

assert.NotNil(t, userApp)
Expand All @@ -44,7 +44,7 @@ func Test_UserFindLedger(t *testing.T) {
func Test_UserGetVersion(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand All @@ -61,7 +61,7 @@ func Test_UserGetVersion(t *testing.T) {
func Test_UserGetPublicKey(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand All @@ -85,7 +85,7 @@ func Test_UserGetPublicKey(t *testing.T) {
func Test_GetAddressPubKeySECP256K1_Zero(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand All @@ -109,7 +109,7 @@ func Test_GetAddressPubKeySECP256K1_Zero(t *testing.T) {
func Test_GetAddressPubKeySECP256K1(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand All @@ -133,7 +133,7 @@ func Test_GetAddressPubKeySECP256K1(t *testing.T) {
func Test_UserPK_HDPaths(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand Down Expand Up @@ -200,7 +200,7 @@ func getDummyTx() []byte {
func Test_UserSign(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand All @@ -219,34 +219,34 @@ func Test_UserSign(t *testing.T) {
}

if err != nil {
t.Fatalf("[GetPK] Error: " + err.Error())
t.Fatalf("[GetPK] Error: %s", err.Error())
return
}

pub2, err := btcec.ParsePubKey(pubKey[:])
if err != nil {
t.Fatalf("[ParsePK] Error: " + err.Error())
t.Fatalf("[ParsePK] Error: %s", err.Error())
return
}

sig2, err := ecdsa.ParseDERSignature(signature[:])
if err != nil {
t.Fatalf("[ParseSig] Error: " + err.Error())
t.Fatalf("[ParseSig] Error: %s", err.Error())
return
}

hash := sha256.Sum256(message)
verified := sig2.Verify(hash[:], pub2)
if !verified {
t.Fatalf("[VerifySig] Error verifying signature: " + err.Error())
t.Fatalf("[VerifySig] Error verifying signature: %s", err.Error())
return
}
}

func Test_UserSign_Fails(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err)
}
defer userApp.Close()

Expand Down
2 changes: 1 addition & 1 deletion validator_app.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
* (c) Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
9 changes: 5 additions & 4 deletions validator_app_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
* (c) Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,15 +17,16 @@
package ledger_cosmos_go

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func Test_ValGetVersion(t *testing.T) {
validatorApp, err := FindLedgerTendermintValidatorApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%s", err.Error())
}
defer validatorApp.Close()

Expand All @@ -40,7 +41,7 @@ func Test_ValGetVersion(t *testing.T) {
func Test_ValGetPublicKey(t *testing.T) {
validatorApp, err := FindLedgerTendermintValidatorApp()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%s", err.Error())
}
defer validatorApp.Close()

Expand Down

0 comments on commit a51269f

Please sign in to comment.