-
Notifications
You must be signed in to change notification settings - Fork 207
/
fulfillment.go
50 lines (42 loc) · 1.36 KB
/
fulfillment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package testutil
import (
"fmt"
"testing"
apptypes "github.com/ovrclk/akash/app/types"
"github.com/ovrclk/akash/types"
"github.com/ovrclk/akash/types/base"
"github.com/stretchr/testify/assert"
crypto "github.com/tendermint/go-crypto"
)
func CreateFulfillment(t *testing.T, app apptypes.Application, provider base.Bytes, key *crypto.PrivKey, deployment base.Bytes, group, order uint64, price uint32) *types.Fulfillment {
fulfillment := Fulfillment(provider, deployment, group, order, price)
fulfillmenttx := &types.TxPayload_TxCreateFulfillment{
TxCreateFulfillment: &types.TxCreateFulfillment{
Fulfillment: fulfillment,
},
}
pubkey := base.PubKey(key.PubKey())
ctx := apptypes.NewContext(&types.Tx{
Key: &pubkey,
Payload: types.TxPayload{
Payload: fulfillmenttx,
},
})
assert.True(t, app.AcceptTx(ctx, fulfillmenttx))
cresp := app.CheckTx(ctx, fulfillmenttx)
assert.True(t, cresp.IsOK())
dresp := app.DeliverTx(ctx, fulfillmenttx)
assert.Len(t, dresp.Log, 0, fmt.Sprint("Log should be empty but is: ", dresp.Log))
assert.True(t, dresp.IsOK())
return fulfillment
}
func Fulfillment(provider base.Bytes, deplyment base.Bytes, group, order uint64, price uint32) *types.Fulfillment {
fulfillment := &types.Fulfillment{
Deployment: deplyment,
Group: group,
Order: order,
Provider: provider,
Price: price,
}
return fulfillment
}