Skip to content

Commit

Permalink
Add additional test permutations
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Aug 3, 2022
1 parent 198ac15 commit f4a7aab
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
20 changes: 12 additions & 8 deletions test/e2e/client/restclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ func (client *FireFlyClient) GetData(t *testing.T, startTime time.Time) (data co
return data
}

func (client *FireFlyClient) GetDataByID(t *testing.T, id *fftypes.UUID) *core.Data {
var data core.Data
path := client.namespaced(urlGetData + "/" + id.String())
resp, err := client.Client.R().
SetResult(&data).
Get(path)
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode(), "GET %s [%d]: %s", path, resp.StatusCode(), resp.String())
return &data
}

func (client *FireFlyClient) GetDataForMessage(t *testing.T, startTime time.Time, msgID *fftypes.UUID) (data core.DataArray) {
path := client.namespaced(urlGetMessages)
path += "/" + msgID.String() + "/data"
Expand Down Expand Up @@ -429,15 +440,8 @@ func (client *FireFlyClient) BroadcastBlobMessage(t *testing.T, topic string) (*
return data, res, err
}

func (client *FireFlyClient) PrivateBlobMessageDatatypeTagged(t *testing.T, topic string, orgNames []string, startTime time.Time) (*core.Data, *resty.Response, error) {
func (client *FireFlyClient) PrivateBlobMessageDatatypeTagged(t *testing.T, topic string, members []core.MemberInput, startTime time.Time) (*core.Data, *resty.Response, error) {
data := client.CreateBlob(t, &core.DatatypeRef{Name: "myblob"})
members := make([]core.MemberInput, len(orgNames))
for i, oName := range orgNames {
// We let FireFly resolve the friendly name of the org to the identity
members[i] = core.MemberInput{
Identity: oName,
}
}
res, err := client.Client.R().
SetBody(core.MessageInOut{
Message: core.Message{
Expand Down
35 changes: 27 additions & 8 deletions test/e2e/multiparty/multi_tenancy.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,37 +151,56 @@ func (suite *NamespaceAliasSuite) TestMultiTenancy() {
toCharlie := []core.MemberInput{
{Identity: suite.testState.org2.Name, Node: "did:firefly:node/charlie"},
}
toAll := []core.MemberInput{
{Identity: suite.testState.org1.Name, Node: "did:firefly:node/alice"},
{Identity: suite.testState.org1.Name, Node: "did:firefly:node/bob"},
{Identity: suite.testState.org2.Name, Node: "did:firefly:node/charlie"},
}

// Verify that private messages on the new namespace succeed
// Alice -> Charlie
resp, err = clientAlice.PrivateMessage("topic", data, toCharlie, "", core.TransactionTypeBatchPin, false, suite.testState.startTime)
resp, err = clientAlice.PrivateMessage("topic", data, toCharlie, "tag1", core.TransactionTypeBatchPin, false, suite.testState.startTime)
require.NoError(suite.T(), err)
assert.Equal(suite.T(), 202, resp.StatusCode())
e2e.WaitForMessageConfirmed(suite.T(), receivedAlice, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedCharlie, core.MessageTypePrivate)
// Charlie -> Alice
resp, err = clientCharlie.PrivateMessage("topic", data, toAlice, "", core.TransactionTypeBatchPin, false, suite.testState.startTime)
resp, err = clientCharlie.PrivateMessage("topic", data, toAlice, "tag2", core.TransactionTypeBatchPin, false, suite.testState.startTime)
require.NoError(suite.T(), err)
assert.Equal(suite.T(), 202, resp.StatusCode())
e2e.WaitForMessageConfirmed(suite.T(), receivedAlice, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedCharlie, core.MessageTypePrivate)
// Charlie -> Bob
resp, err = clientCharlie.PrivateMessage("topic", data, toBob, "", core.TransactionTypeBatchPin, false, suite.testState.startTime)
// Charlie -> Alice+Bob
resp, err = clientCharlie.PrivateMessage("topic", data, toAll, "tag3", core.TransactionTypeBatchPin, false, suite.testState.startTime)
require.NoError(suite.T(), err)
assert.Equal(suite.T(), 202, resp.StatusCode())
e2e.WaitForMessageConfirmed(suite.T(), receivedAlice, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedBob, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedCharlie, core.MessageTypePrivate)
// Alice -> Bob
resp, err = clientAlice.PrivateMessage("topic", data, toBob, "", core.TransactionTypeBatchPin, false, suite.testState.startTime)
resp, err = clientAlice.PrivateMessage("topic", data, toBob, "tag4", core.TransactionTypeBatchPin, false, suite.testState.startTime)
require.NoError(suite.T(), err)
assert.Equal(suite.T(), 202, resp.StatusCode())
e2e.WaitForMessageConfirmed(suite.T(), receivedAlice, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedBob, core.MessageTypePrivate)
// Bob -> Alice+Charlie (blob transfer)
dataRef, resp, err := clientBob.PrivateBlobMessageDatatypeTagged(suite.T(), "topic", toAll, suite.testState.startTime)
require.NoError(suite.T(), err)
assert.Equal(suite.T(), 202, resp.StatusCode())
assert.NotNil(suite.T(), dataRef.Blob.Hash)
e2e.WaitForMessageConfirmed(suite.T(), receivedAlice, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedBob, core.MessageTypePrivate)
e2e.WaitForMessageConfirmed(suite.T(), receivedCharlie, core.MessageTypePrivate)

dataRecv := clientAlice.GetDataByID(suite.T(), dataRef.ID)
assert.Equal(suite.T(), dataRef.Blob.Hash, dataRecv.Blob.Hash)
dataRecv = clientCharlie.GetDataByID(suite.T(), dataRef.ID)
assert.Equal(suite.T(), dataRef.Blob.Hash, dataRecv.Blob.Hash)

messages := clientAlice.GetMessages(suite.T(), suite.testState.startTime, core.MessageTypePrivate, "topic")
assert.Len(suite.T(), messages, 3)
assert.Len(suite.T(), messages, 5)
messages = clientBob.GetMessages(suite.T(), suite.testState.startTime, core.MessageTypePrivate, "topic")
assert.Len(suite.T(), messages, 2)
messages = clientCharlie.GetMessages(suite.T(), suite.testState.startTime, core.MessageTypePrivate, "topic")
assert.Len(suite.T(), messages, 3)
messages = clientCharlie.GetMessages(suite.T(), suite.testState.startTime, core.MessageTypePrivate, "topic")
assert.Len(suite.T(), messages, 4)
}
10 changes: 6 additions & 4 deletions test/e2e/multiparty/onchain_offchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,12 @@ func (suite *OnChainOffChainTestSuite) TestE2EPrivateBlobDatatypeTagged() {

var resp *resty.Response

data, resp, err := suite.testState.client1.PrivateBlobMessageDatatypeTagged(suite.T(), "topic1", []string{
suite.testState.org1.Name,
suite.testState.org2.Name,
}, suite.testState.startTime)
members := []core.MemberInput{
{Identity: suite.testState.org1.Name},
{Identity: suite.testState.org2.Name},
}

data, resp, err := suite.testState.client1.PrivateBlobMessageDatatypeTagged(suite.T(), "topic1", members, suite.testState.startTime)
require.NoError(suite.T(), err)
assert.Equal(suite.T(), 202, resp.StatusCode())
assert.Empty(suite.T(), data.Blob.Name)
Expand Down

0 comments on commit f4a7aab

Please sign in to comment.