Skip to content

Commit

Permalink
conditional assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Oct 22, 2024
1 parent c744229 commit 5753fd5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
3 changes: 2 additions & 1 deletion internal/controller/system/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func NewFXModule(configuration ModuleConfiguration) fx.Option {
}))
}

if configuration.NSCacheConfiguration.MaxCount != 0 {
// TEMP enable again
if false && configuration.NSCacheConfiguration.MaxCount != 0 {
options = append(options, WithUpdateParser(func(oldParser ledgercontroller.NumscriptParser) ledgercontroller.NumscriptParser {
if oldParser == nil {
oldParser = ledgercontroller.NewDefaultNumscriptParser()
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/api_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,14 @@ var _ = Context("Ledger engine tests", func() {
Expect(err).To(Succeed())
})
It("should respond with an error", func() {
var expectedErr string
if data.numscriptRewrite {
expectedErr = "INTERPRETER_RUNTIME"
} else {
expectedErr = "INSUFFICIENT_FUND"
}
Expect(bulkResponse[1].Type).To(Equal(components.V2BulkElementResultType("ERROR")))
Expect(bulkResponse[1].V2BulkElementResultError.ErrorCode).To(Equal("INTERPRETER_RUNTIME"))
Expect(bulkResponse[1].V2BulkElementResultError.ErrorCode).To(Equal(expectedErr))
})
})
})
Expand Down
43 changes: 35 additions & 8 deletions test/e2e/api_transactions_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,15 @@ var _ = Context("Ledger accounts list API tests", func() {
}}
})
It("should fail", func() {
var expectedErr string
if data.numscriptRewrite {
expectedErr = string(components.V2ErrorsEnumInterpreterRuntime)
} else {
expectedErr = string(components.V2ErrorsEnumInsufficientFund)
}

Expect(err).To(HaveOccurred())
Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumInterpreterRuntime)))
Expect(err).To(HaveErrorCode(expectedErr))
})
})
When("with nil amount", func() {
Expand Down Expand Up @@ -334,9 +341,17 @@ var _ = Context("Ledger accounts list API tests", func() {
Ledger: "default",
}
})
It("should fail with "+string(components.V2ErrorsEnumInterpreterRuntime)+" code", func() {

var expectedErr string
if data.numscriptRewrite {
expectedErr = string(components.V2ErrorsEnumInterpreterRuntime)
} else {
expectedErr = string(components.V2ErrorsEnumCompilationFailed)
}

It("should fail with "+expectedErr+" code", func() {
Expect(err).NotTo(Succeed())
Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumInterpreterRuntime)))
Expect(err).To(HaveErrorCode(expectedErr))
})
})
When("using a negative amount in the script with a variable", func() {
Expand All @@ -361,9 +376,16 @@ var _ = Context("Ledger accounts list API tests", func() {
Ledger: "default",
}
})
It("should fail with "+string(components.V2ErrorsEnumInterpreterRuntime)+" code", func() {

var expectedErr string
if data.numscriptRewrite {
expectedErr = string(components.V2ErrorsEnumInterpreterRuntime)
} else {
expectedErr = string(components.V2ErrorsEnumCompilationFailed)
}
It("should fail with "+expectedErr+" code", func() {
Expect(err).NotTo(Succeed())
Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumInterpreterRuntime)))
Expect(err).To(HaveErrorCode(expectedErr))
})
})
Context("with error on script", func() {
Expand All @@ -380,9 +402,15 @@ var _ = Context("Ledger accounts list API tests", func() {
Ledger: "default",
}
})
It("should fail with "+string(components.V2ErrorsEnumInterpreterParse)+" code", func() {
var expectedErr string
if data.numscriptRewrite {
expectedErr = string(components.V2ErrorsEnumInterpreterParse)
} else {
expectedErr = string(components.V2ErrorsEnumCompilationFailed)
}
It("should fail with "+expectedErr+" code", func() {
Expect(err).NotTo(Succeed())
Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumInterpreterParse)))
Expect(err).To(HaveErrorCode(expectedErr))
})
})
Context("with no postings", func() {
Expand Down Expand Up @@ -498,5 +526,4 @@ var _ = Context("Ledger accounts list API tests", func() {
})
})
}

})

0 comments on commit 5753fd5

Please sign in to comment.