mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
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:
@@ -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() {
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user