mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-03 11:53:43 +02:00
src/api/eosio_contract.go: Adding EosioContractFactory function
This commit is contained in:
parent
9fcffe375a
commit
d8c8c14edc
2 changed files with 19 additions and 0 deletions
|
|
@ -14,6 +14,10 @@ type EosioContract struct {
|
||||||
block_time float64
|
block_time float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EosioContractFactory(args ApiArguments) ApiInterface {
|
||||||
|
return NewEosioContract(args.Url, float64(args.NumBlocks / 2))
|
||||||
|
}
|
||||||
|
|
||||||
func NewEosioContract(url string, block_time float64) EosioContract {
|
func NewEosioContract(url string, block_time float64) EosioContract {
|
||||||
return EosioContract{
|
return EosioContract{
|
||||||
client: contract_api.Client{
|
client: contract_api.Client{
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,21 @@ import (
|
||||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestEosioContractFactory(t *testing.T) {
|
||||||
|
|
||||||
|
api := EosioContractFactory(ApiArguments{
|
||||||
|
Url: "https://atomic.example.com",
|
||||||
|
NumBlocks: 120,
|
||||||
|
})
|
||||||
|
|
||||||
|
expected := NewEosioContract("https://atomic.example.com", 60)
|
||||||
|
|
||||||
|
assert.IsType(t, expected, api)
|
||||||
|
assert.Equal(t, expected.client.Url, api.(EosioContract).client.Url)
|
||||||
|
assert.Equal(t, expected.client.Host, api.(EosioContract).client.Host)
|
||||||
|
assert.Equal(t, expected.block_time, api.(EosioContract).block_time)
|
||||||
|
}
|
||||||
|
|
||||||
func TestEosioContractLogInfo(t *testing.T) {
|
func TestEosioContractLogInfo(t *testing.T) {
|
||||||
|
|
||||||
api := NewEosioContract("https://atomic.example.com", 120)
|
api := NewEosioContract("https://atomic.example.com", 120)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue