Skip to content

Commit

Permalink
Fix: tezos domains (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Jun 24, 2021
1 parent 587169e commit ca71030
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 47 deletions.
4 changes: 2 additions & 2 deletions cmd/api/handlers/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,11 @@ type TezosDomain struct {
// FromModel -
func (td *TezosDomain) FromModel(domain tezosdomain.TezosDomain) {
td.Name = domain.Name
td.Expiration = domain.Expiration
td.Expiration = domain.Expiration.UTC()
td.Network = domain.Network.String()
td.Address = domain.Address
td.Level = domain.Level
td.Timestamp = domain.Timestamp
td.Timestamp = domain.Timestamp.UTC()
td.Data = domain.Data
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/metrics/bigmapdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func initHandlers() {
contractHandlers.NewTZIP(ctx.BigMapDiffs, ctx.Blocks, ctx.Storage, ctx.TZIP, ctx.RPC, ctx.SharePath, ctx.Config.IPFSGateways),
)
bigMapDiffHandlers = append(bigMapDiffHandlers,
contractHandlers.NewTezosDomains(ctx.Storage, ctx.Operations, ctx.TezosDomainsContracts, ctx.SharePath),
contractHandlers.NewTezosDomains(ctx.Storage, ctx.Operations, ctx.TezosDomainsContracts),
)
}

Expand Down
1 change: 1 addition & 0 deletions configs/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ipfs:

domains:
edo2net: KT1KP2Yy6MNkYKkHqroGBZ7KFN5NdNfnUHHv
mainnet: KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS

api:
project_name: api
Expand Down
25 changes: 13 additions & 12 deletions internal/handlers/tezos_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const (
type TezosDomain struct {
storage models.GeneralRepository
operations operation.Repository
shareDir string

contracts map[contract.Address]struct{}
ptrs map[contract.Address]ptrs
Expand All @@ -37,7 +36,7 @@ type ptrs struct {
}

// NewTezosDomains -
func NewTezosDomains(storage models.GeneralRepository, operations operation.Repository, contracts map[types.Network]string, shareDir string) *TezosDomain {
func NewTezosDomains(storage models.GeneralRepository, operations operation.Repository, contracts map[types.Network]string) *TezosDomain {
addresses := make(map[contract.Address]struct{})
for k, v := range contracts {
addresses[contract.Address{
Expand All @@ -46,7 +45,7 @@ func NewTezosDomains(storage models.GeneralRepository, operations operation.Repo
}] = struct{}{}
}
return &TezosDomain{
storage, operations, shareDir, addresses, make(map[contract.Address]ptrs),
storage, operations, addresses, make(map[contract.Address]ptrs),
}
}

Expand All @@ -58,9 +57,11 @@ func (td *TezosDomain) Do(bmd *bigmapdiff.BigMapDiff, storage *ast.TypedAst) (bo
}
switch bmd.Ptr {
case *ptr.records:
return true, nil, td.updateRecordsTZIP(bmd)
items, err := td.updateRecordsTZIP(bmd)
return true, items, err
case *ptr.expiry:
return true, nil, td.updateExpirationDate(bmd)
items, err := td.updateExpirationDate(bmd)
return true, items, err
}
return false, nil, nil
}
Expand Down Expand Up @@ -131,13 +132,13 @@ func (td *TezosDomain) getPointers(address contract.Address, bmd *bigmapdiff.Big
return nil
}

func (td *TezosDomain) updateRecordsTZIP(bmd *bigmapdiff.BigMapDiff) error {
func (td *TezosDomain) updateRecordsTZIP(bmd *bigmapdiff.BigMapDiff) ([]models.Model, error) {
if len(bmd.KeyStrings) == 0 || len(bmd.ValueStrings) == 0 {
return errors.Errorf("Invalid tezos domains big map diff: %d", bmd.GetID())
return nil, errors.Errorf("Invalid tezos domains big map diff: %d", bmd.GetID())
}
address, err := td.getAddress(bmd.Value)
if err != nil {
return err
return nil, err
}
tezosDomain := tezosdomain.TezosDomain{
Network: bmd.Network,
Expand All @@ -148,12 +149,12 @@ func (td *TezosDomain) updateRecordsTZIP(bmd *bigmapdiff.BigMapDiff) error {
if address != nil {
tezosDomain.Address = *address
}
return td.storage.UpdateFields(models.DocTezosDomains, tezosDomain.GetID(), tezosDomain, "Name", "Address", "Network", "Level", "Timestamp")
return []models.Model{&tezosDomain}, nil
}

func (td *TezosDomain) updateExpirationDate(bmd *bigmapdiff.BigMapDiff) error {
func (td *TezosDomain) updateExpirationDate(bmd *bigmapdiff.BigMapDiff) ([]models.Model, error) {
if len(bmd.KeyStrings) == 0 {
return errors.Errorf("Invalid tezos domains big map diff: %d", bmd.GetID())
return nil, errors.Errorf("Invalid tezos domains big map diff: %d", bmd.GetID())
}
ts := gjson.ParseBytes(bmd.Value).Get("int").Int()
date := time.Unix(ts, 0).UTC()
Expand All @@ -162,7 +163,7 @@ func (td *TezosDomain) updateExpirationDate(bmd *bigmapdiff.BigMapDiff) error {
Network: bmd.Network,
Expiration: date,
}
return td.storage.UpdateFields(models.DocTezosDomains, tezosDomain.GetID(), tezosDomain, "Expiration")
return []models.Model{&tezosDomain}, nil
}

func (td *TezosDomain) getAddress(value []byte) (*string, error) {
Expand Down
152 changes: 152 additions & 0 deletions internal/handlers/tezos_domains_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package handlers

import (
"reflect"
"testing"
"time"

"github.com/baking-bad/bcdhub/internal/bcd/ast"
"github.com/baking-bad/bcdhub/internal/models"
"github.com/baking-bad/bcdhub/internal/models/bigmapdiff"
"github.com/baking-bad/bcdhub/internal/models/contract"
mock_general "github.com/baking-bad/bcdhub/internal/models/mock"
mock_operations "github.com/baking-bad/bcdhub/internal/models/mock/operation"
"github.com/baking-bad/bcdhub/internal/models/operation"
"github.com/baking-bad/bcdhub/internal/models/tezosdomain"
"github.com/baking-bad/bcdhub/internal/models/types"
"github.com/golang/mock/gomock"
)

func TestTezosDomain_Do(t *testing.T) {
ctrlStorage := gomock.NewController(t)
defer ctrlStorage.Finish()
generalRepo := mock_general.NewMockGeneralRepository(ctrlStorage)

ctrlOperationRepo := gomock.NewController(t)
defer ctrlOperationRepo.Finish()
operationsRepo := mock_operations.NewMockRepository(ctrlOperationRepo)

operationsRepo.
EXPECT().
GetByIDs([]int64{11136755}).
Return([]operation.Operation{
{
ID: 11136755,
DeffatedStorage: []byte(`{"prim":"Pair","args":[[{"int":"1260"},{"prim":"Pair","args":[{"prim":"Pair","args":[{"int":"1261"},{"int":"1262"}]},{"prim":"Pair","args":[{"int":"1263"},{"int":"10150"}]}]},{"prim":"Pair","args":[{"bytes":"01ebb657570e494e8a7bd43ac3bf7cfd0267a32a9f00"},{"int":"1264"}]},{"int":"1265"},{"int":"1266"}],[{"bytes":"014796e76af90e6327adfab057bbbe0375cd2c8c1000"},{"bytes":"015c6799f783b8d118b704267f634c5d24d19e9a9f00"},{"bytes":"0168e9b7d86646e312c76dfbedcbcdb24320875a3600"},{"bytes":"019178a76f3c41a9541d2291cad37dd5fb96a6850500"},{"bytes":"01ac3638385caa4ad8126ea84e061f4f49baa44d3c00"},{"bytes":"01d2a0974172cf6fc8b1eefdebd5bea681616f7c6f00"}]]}`),
},
}, nil).
AnyTimes()

ts := time.Now()

type args struct {
bmd *bigmapdiff.BigMapDiff
storage string
}
tests := []struct {
name string
args args
want1 []models.Model
want bool
wantErr bool
}{
{
name: "test 1: record",
args: args{
bmd: &bigmapdiff.BigMapDiff{
ID: 10160561,
Ptr: 1264,
KeyHash: "exprvG95A3YxzqRnRUNkeJH6sXL3at8TEPNzsRLpjuL3aoGk4MuWEk",
Level: 1529158,
Contract: "KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS",
Network: types.Mainnet,
Timestamp: ts,
ProtocolID: 11,
OperationID: 11136755,
KeyStrings: []string{"sodagenjo.tez"},
ValueStrings: []string{
"tz2Xd3x8mbRMpmLeRGMfuRAHNYgWDim53BQh",
"sodagenjo.tez",
"tz2Xd3x8mbRMpmLeRGMfuRAHNYgWDim53BQh",
},
Key: []byte(`{"bytes":"736f646167656e6a6f2e74657a"}`),
Value: []byte(`{"prim":"Pair","args":[{"prim":"Pair","args":[{"prim":"Pair","args":[{"prim":"Some","args":[{"bytes":"0001ffa97094ca718ef3c9b42416bd7cd8013b4176bf"}]},[]]},{"prim":"Pair","args":[{"prim":"Some","args":[{"bytes":"736f646167656e6a6f2e74657a"}]},[]]}]},{"prim":"Pair","args":[{"prim":"Pair","args":[{"int":"2"},{"bytes":"0001ffa97094ca718ef3c9b42416bd7cd8013b4176bf"}]},{"prim":"Some","args":[{"int":"10149"}]}]}]}`),
},
storage: `{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"lambda","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"bytes"},{"prim":"address"}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"bytes"}],"annots":["%data"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"timestamp"}],"annots":["%expiry_map"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%metadata"]},{"prim":"nat","annots":["%next_tzip12_token_id"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"address","annots":["%owner"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"option","args":[{"prim":"address"}],"annots":["%address"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%data"]}]},{"prim":"pair","args":[{"prim":"option","args":[{"prim":"bytes"}],"annots":["%expiry_key"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%level"]},{"prim":"address","annots":["%owner"]}]},{"prim":"option","args":[{"prim":"nat"}],"annots":["%tzip12_token_id"]}]}]}],"annots":["%records"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"address"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]},{"prim":"option","args":[{"prim":"bytes"}],"annots":["%name"]}]},{"prim":"address","annots":["%owner"]}]}],"annots":["%reverse_records"]},{"prim":"big_map","args":[{"prim":"nat"},{"prim":"bytes"}],"annots":["%tzip12_tokens"]}]}]}]}]},{"prim":"pair","args":[{"prim":"list","args":[{"prim":"operation"}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"bytes"}],"annots":["%data"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"timestamp"}],"annots":["%expiry_map"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%metadata"]},{"prim":"nat","annots":["%next_tzip12_token_id"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"address","annots":["%owner"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"option","args":[{"prim":"address"}],"annots":["%address"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%data"]}]},{"prim":"pair","args":[{"prim":"option","args":[{"prim":"bytes"}],"annots":["%expiry_key"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%level"]},{"prim":"address","annots":["%owner"]}]},{"prim":"option","args":[{"prim":"nat"}],"annots":["%tzip12_token_id"]}]}]}],"annots":["%records"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"address"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]},{"prim":"option","args":[{"prim":"bytes"}],"annots":["%name"]}]},{"prim":"address","annots":["%owner"]}]}],"annots":["%reverse_records"]},{"prim":"big_map","args":[{"prim":"nat"},{"prim":"bytes"}],"annots":["%tzip12_tokens"]}]}]}]}]}]}],"annots":["%actions"]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"bytes"}],"annots":["%data"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"timestamp"}],"annots":["%expiry_map"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%metadata"]},{"prim":"nat","annots":["%next_tzip12_token_id"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"address","annots":["%owner"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"option","args":[{"prim":"address"}],"annots":["%address"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%data"]}]},{"prim":"pair","args":[{"prim":"option","args":[{"prim":"bytes"}],"annots":["%expiry_key"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%level"]},{"prim":"address","annots":["%owner"]}]},{"prim":"option","args":[{"prim":"nat"}],"annots":["%tzip12_token_id"]}]}]}],"annots":["%records"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"address"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]},{"prim":"option","args":[{"prim":"bytes"}],"annots":["%name"]}]},{"prim":"address","annots":["%owner"]}]}],"annots":["%reverse_records"]},{"prim":"big_map","args":[{"prim":"nat"},{"prim":"bytes"}],"annots":["%tzip12_tokens"]}]}]}],"annots":["%store"]}]},{"prim":"set","args":[{"prim":"address"}],"annots":["%trusted_senders"]}]}`,
},
want: true,
want1: []models.Model{
&tezosdomain.TezosDomain{
Name: "sodagenjo.tez",
Network: types.Mainnet,
Address: "tz2Xd3x8mbRMpmLeRGMfuRAHNYgWDim53BQh",
Level: 1529158,
Timestamp: ts,
},
},
wantErr: false,
}, {
name: "test 2: expiry map",
args: args{
bmd: &bigmapdiff.BigMapDiff{
ID: 10160562,
Ptr: 1262,
KeyHash: "exprvG95A3YxzqRnRUNkeJH6sXL3at8TEPNzsRLpjuL3aoGk4MuWEk",
Level: 1529158,
Contract: "KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS",
Network: types.Mainnet,
Timestamp: ts,
ProtocolID: 11,
OperationID: 11136755,
KeyStrings: []string{"sodagenjo.tez"},
ValueStrings: []string{},
Key: []byte(`{"bytes":"736f646167656e6a6f2e74657a"}`),
Value: []byte(`{"int":"1656071422"}`),
},
storage: `{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"lambda","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"bytes"},{"prim":"address"}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"bytes"}],"annots":["%data"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"timestamp"}],"annots":["%expiry_map"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%metadata"]},{"prim":"nat","annots":["%next_tzip12_token_id"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"address","annots":["%owner"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"option","args":[{"prim":"address"}],"annots":["%address"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%data"]}]},{"prim":"pair","args":[{"prim":"option","args":[{"prim":"bytes"}],"annots":["%expiry_key"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%level"]},{"prim":"address","annots":["%owner"]}]},{"prim":"option","args":[{"prim":"nat"}],"annots":["%tzip12_token_id"]}]}]}],"annots":["%records"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"address"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]},{"prim":"option","args":[{"prim":"bytes"}],"annots":["%name"]}]},{"prim":"address","annots":["%owner"]}]}],"annots":["%reverse_records"]},{"prim":"big_map","args":[{"prim":"nat"},{"prim":"bytes"}],"annots":["%tzip12_tokens"]}]}]}]}]},{"prim":"pair","args":[{"prim":"list","args":[{"prim":"operation"}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"bytes"}],"annots":["%data"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"timestamp"}],"annots":["%expiry_map"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%metadata"]},{"prim":"nat","annots":["%next_tzip12_token_id"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"address","annots":["%owner"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"option","args":[{"prim":"address"}],"annots":["%address"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%data"]}]},{"prim":"pair","args":[{"prim":"option","args":[{"prim":"bytes"}],"annots":["%expiry_key"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%level"]},{"prim":"address","annots":["%owner"]}]},{"prim":"option","args":[{"prim":"nat"}],"annots":["%tzip12_token_id"]}]}]}],"annots":["%records"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"address"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]},{"prim":"option","args":[{"prim":"bytes"}],"annots":["%name"]}]},{"prim":"address","annots":["%owner"]}]}],"annots":["%reverse_records"]},{"prim":"big_map","args":[{"prim":"nat"},{"prim":"bytes"}],"annots":["%tzip12_tokens"]}]}]}]}]}]}],"annots":["%actions"]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"bytes"}],"annots":["%data"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"timestamp"}],"annots":["%expiry_map"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%metadata"]},{"prim":"nat","annots":["%next_tzip12_token_id"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"address","annots":["%owner"]},{"prim":"big_map","args":[{"prim":"bytes"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"option","args":[{"prim":"address"}],"annots":["%address"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%data"]}]},{"prim":"pair","args":[{"prim":"option","args":[{"prim":"bytes"}],"annots":["%expiry_key"]},{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]}]}]},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%level"]},{"prim":"address","annots":["%owner"]}]},{"prim":"option","args":[{"prim":"nat"}],"annots":["%tzip12_token_id"]}]}]}],"annots":["%records"]}]},{"prim":"pair","args":[{"prim":"big_map","args":[{"prim":"address"},{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"map","args":[{"prim":"string"},{"prim":"bytes"}],"annots":["%internal_data"]},{"prim":"option","args":[{"prim":"bytes"}],"annots":["%name"]}]},{"prim":"address","annots":["%owner"]}]}],"annots":["%reverse_records"]},{"prim":"big_map","args":[{"prim":"nat"},{"prim":"bytes"}],"annots":["%tzip12_tokens"]}]}]}],"annots":["%store"]}]},{"prim":"set","args":[{"prim":"address"}],"annots":["%trusted_senders"]}]}`,
},
want: true,
want1: []models.Model{
&tezosdomain.TezosDomain{
Name: "sodagenjo.tez",
Expiration: time.Unix(1656071422, 0).UTC(),
Network: types.Mainnet,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
td := &TezosDomain{
storage: generalRepo,
operations: operationsRepo,
contracts: map[contract.Address]struct{}{
{
Address: "KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS",
Network: types.Mainnet,
}: {},
},
ptrs: make(map[contract.Address]ptrs),
}

var storageType ast.TypedAst
if err := json.UnmarshalFromString(tt.args.storage, &storageType); err != nil {
t.Errorf("UnmarshalFromString() error = %v", err)
return
}

got, got1, err := td.Do(tt.args.bmd, &storageType)
if (err != nil) != tt.wantErr {
t.Errorf("TezosDomain.Do() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("TezosDomain.Do() got = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got1, tt.want1) {
t.Errorf("TezosDomain.Do() got1 = %v, want %v", got1, tt.want1)
}
})
}
}
1 change: 0 additions & 1 deletion internal/models/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type GeneralRepository interface {
GetByID(output Model) error
GetByNetwork(network types.Network, index string) ([]Model, error)
UpdateDoc(model Model) (err error)
UpdateFields(index string, id int64, data interface{}, fields ...string) error

GetNetworkCountStats(network types.Network) (map[string]int64, error)
GetDateHistogram(period string, opts ...HistogramOption) ([][]float64, error)
Expand Down
Loading

0 comments on commit ca71030

Please sign in to comment.