linter: Enable error checking linter (#766)

* golangci: Enable err checking linter to expose unchecked errors.

* gct: handle errors across the board

* gct: handle errors NOTE: Found bug in FTX (WIP)

* linter: fix issues

* ftx/exchanges: fix bug where error was being returned when setting pair management variables to an already enabled state

* bitmex: fix bug where a dangly supported asset in config danglied up the place.

* linter: fix more linter issues

* linter: fix my terrible spelling.

* currency: fix test

* exchanges: fix tests

* logger: fix test

* exchanges: fix tests

* glorious: nits

* vm: revert rm variable and instigate test
This commit is contained in:
Ryan O'Hara-Reid
2021-08-30 14:06:40 +10:00
committed by GitHub
parent c9ab0b1164
commit 8020e1ec6a
99 changed files with 814 additions and 293 deletions

View File

@@ -288,7 +288,11 @@ func (vm *VM) getHash() string {
log.Errorln(log.GCTScriptMgr, err)
}
contents = append(contents, vm.ShortName()...)
return hex.EncodeToString(crypto.GetSHA256(contents))
hash, err := crypto.GetSHA256(contents)
if err != nil {
log.Errorln(log.GCTScriptMgr, err)
}
return hex.EncodeToString(hash)
}
func (vmc *vmscount) add() {

View File

@@ -25,8 +25,8 @@ var (
testBrokenScript = filepath.Join("..", "..", "testdata", "gctscript", "broken.gct")
testScriptRunner = filepath.Join("..", "..", "testdata", "gctscript", "timer.gct")
testScriptRunner1s = filepath.Join("..", "..", "testdata", "gctscript", "1s_timer.gct")
testScriptRunnerInvalid = filepath.Join("..", "..", "testdata", "gctscript", "invalid_timer.gct")
testScriptRunnerNegative = filepath.Join("..", "..", "testdata", "gctscript", "negative_timer.gct")
testScriptRunnerInvalid = filepath.Join("..", "..", "testdata", "gctscript", "invalid_timer.gct")
)
func TestMain(m *testing.M) {
@@ -325,6 +325,34 @@ func TestVMWithRunnerNegativeTimer(t *testing.T) {
}
}
func TestVMWithRunnerInvalidTimer(t *testing.T) {
manager := GctScriptManager{
config: configHelper(true, true, maxTestVirtualMachines),
started: 1,
}
vmCount := VMSCount.Len()
VM := manager.New()
if VM == nil {
t.Fatal("Failed to allocate new VM exiting")
}
err := VM.Load(testScriptRunnerInvalid)
if err != nil {
t.Fatal(err)
}
if VMSCount.Len() == vmCount {
t.Fatal("expected VM count to increase")
}
VM.CompileAndRun()
err = VM.Shutdown()
if err == nil {
t.Fatal("VM should not be running with invalid timer")
}
if VMSCount.Len() == vmCount-1 {
t.Fatal("expected VM count to decrease")
}
}
func TestShutdownAll(t *testing.T) {
manager := GctScriptManager{
config: configHelper(true, true, maxTestVirtualMachines),