Skip to content

Commit

Permalink
chore(clients): embed mock clients config
Browse files Browse the repository at this point in the history
  • Loading branch information
saitofun committed Feb 18, 2024
1 parent a949a3f commit 37b3f06
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 76 deletions.
77 changes: 77 additions & 0 deletions clients/clients
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[
{
"clientDID": "did:ethr:0x9d9250fb4e08ba7a858fe7196a6ba946c6083ff0",
"projects": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
]
},
{
"clientDID": "did:key:z6MkeeChrUs1EoKkNNzoy9FwJJb9gNQ92UT8kcXZHMbwj67B",
"projects": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
]
},
{
"clientDID": "did:example:d23dd687a7dc6787646f2eb98d0",
"projects": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
]
}
]
86 changes: 10 additions & 76 deletions clients/manager.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package clients

import (
_ "embed" // embed mock clients configuration
"encoding/json"
"sync"
)

var (
//go:embed clients
mockClientsConfig []byte
)

type Client struct {
ClientDID string `json:"clientDID"`
Projects []uint64 `json:"projects"`
Expand Down Expand Up @@ -48,82 +55,9 @@ func (mgr *Manager) AddClient(c *Client) {
func (mgr *Manager) syncFromContract() {}

func (mgr *Manager) fillByMockClients() {
clients := []*Client{
{
ClientDID: "did:ethr:0x9d9250fb4e08ba7a858fe7196a6ba946c6083ff0",
Projects: []uint64{
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
},
},
{
ClientDID: "did:key:z6MkeeChrUs1EoKkNNzoy9FwJJb9gNQ92UT8kcXZHMbwj67B",
Projects: []uint64{
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
},
},
{
ClientDID: "did:example:d23dd687a7dc6787646f2eb98d0",
Projects: []uint64{
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
},
},
clients := make([]*Client, 0)
if err := json.Unmarshal(mockClientsConfig, &clients); err != nil {
panic(err)
}
for _, c := range clients {
c.projects = make(map[uint64]struct{})
Expand Down

0 comments on commit 37b3f06

Please sign in to comment.