Skip to content

Commit

Permalink
add address to process
Browse files Browse the repository at this point in the history
  • Loading branch information
antho1404 committed Mar 12, 2020
1 parent 101399d commit e4ae1c0
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 75 deletions.
20 changes: 12 additions & 8 deletions e2e/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"context"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/mesg-foundation/engine/hash"
"github.com/mesg-foundation/engine/ownership"
"github.com/mesg-foundation/engine/process"
pb "github.com/mesg-foundation/engine/protobuf/api"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
)

var testProcessHash hash.Hash
Expand Down Expand Up @@ -58,21 +60,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:"-"'
];
}
2 changes: 2 additions & 0 deletions x/process/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/mesg-foundation/engine/process"
processpb "github.com/mesg-foundation/engine/process"
"github.com/mesg-foundation/engine/x/process/internal/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/log"
)

Expand Down Expand Up @@ -46,6 +47,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 e4ae1c0

Please sign in to comment.