Skip to content

Commit

Permalink
Merge pull request #1723 from mesg-foundation/feature/process-address
Browse files Browse the repository at this point in the history
Add address to process
  • Loading branch information
Nicolas Mahé authored Mar 13, 2020
2 parents 9dae44f + 69ba5ac commit ccf5ecc
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 75 deletions.
18 changes: 10 additions & 8 deletions e2e/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,23 @@ func testProcess(t *testing.T) {
p, err := client.ProcessClient.Get(context.Background(), &pb.GetProcessRequest{Hash: testProcessHash})
require.NoError(t, err)
require.True(t, p.Equal(&process.Process{
Hash: p.Hash,
Name: req.Name,
Nodes: req.Nodes,
Edges: req.Edges,
Hash: p.Hash,
Address: sdk.AccAddress(crypto.AddressHash(p.Hash)).String(),
Name: req.Name,
Nodes: req.Nodes,
Edges: req.Edges,
}))
processHash = p.Hash
})
t.Run("lcd", func(t *testing.T) {
var p *process.Process
lcdGet(t, "process/get/"+testProcessHash.String(), &p)
require.True(t, p.Equal(&process.Process{
Hash: p.Hash,
Name: req.Name,
Nodes: req.Nodes,
Edges: req.Edges,
Hash: p.Hash,
Address: sdk.AccAddress(crypto.AddressHash(p.Hash)).String(),
Name: req.Name,
Nodes: req.Nodes,
Edges: req.Edges,
}))
})
})
Expand Down
140 changes: 73 additions & 67 deletions process/process.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions protobuf/types/process.proto
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,8 @@ message Process {
repeated Edge edges = 5 [
(gogoproto.moretags) = 'hash:"name:5" validate:"dive,required"'
];

string address = 6 [
(gogoproto.moretags) = 'hash:"-"'
];
}
1 change: 1 addition & 0 deletions x/process/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateProcess) (*processpb
Edges: msg.Request.Edges,
}
p.Hash = hash.Dump(p)
p.Address = sdk.AccAddress(crypto.AddressHash(p.Hash)).String()
if store.Has(p.Hash) {
return nil, fmt.Errorf("process %q already exists", p.Hash)
}
Expand Down

0 comments on commit ccf5ecc

Please sign in to comment.