Skip to content

Commit

Permalink
PR FIXUP - Expand concurrent test to correctly establish SEC
Browse files Browse the repository at this point in the history
With Fred's help :)
  • Loading branch information
AndrewSisley committed Nov 18, 2024
1 parent 46435f8 commit c4ab423
Showing 1 changed file with 48 additions and 91 deletions.
139 changes: 48 additions & 91 deletions tests/integration/query/commits/branchables/peer_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,30 @@ func TestQueryCommitsBranchables_HandlesConcurrentUpdatesAcrossPeerConnection(t
},
testUtils.WaitForSync{},
testUtils.UpdateDoc{
// Update node 1 after the peer connection has been established, this will cause the `Shahzad` commit
// to be synced to node 0, as well as the related collection commits.
NodeID: immutable.Some(1),
Doc: `{
"name": "Chris"
}`,
},
testUtils.WaitForSync{},
// Note: node 1 does not recieve the first update from node 0 as it occured before the nodes were connected
// node 0 has it as it recieved it when recieving the second update from node 1. The cids and blocks remain
// consistent across both nodes (minus the missing commits).
testUtils.Request{
testUtils.UpdateDoc{
// Update node 0 after `Chris` and `Shahzad` have synced to node 0. As this update happens after the peer
// connection has been established, this will cause the `Fred` and `Addo` doc commits, and their corresponding
// collection-level commits to sync to node 1.
//
// Now, all nodes should have a full history, including the 'offline' changes made before establishing the
// peer connection.
NodeID: immutable.Some(0),
Doc: `{
"name": "Addo"
}`,
},
testUtils.WaitForSync{},
testUtils.Request{
// Strong eventual consistency must now have been established across both nodes, the result of this query
// *must* exactly match across both nodes.
Request: `query {
commits {
cid
Expand All @@ -75,13 +88,16 @@ func TestQueryCommitsBranchables_HandlesConcurrentUpdatesAcrossPeerConnection(t
Results: map[string]any{
"commits": []map[string]any{
{
"cid": testUtils.NewUniqueCid("collection, update2"),
"cid": testUtils.NewUniqueCid("collection, update3"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("collection, update2"),
},
{
"cid": testUtils.NewUniqueCid("collection, node1 update1"),
},
{
"cid": testUtils.NewUniqueCid("doc, update2"),
"cid": testUtils.NewUniqueCid("doc, update3"),
},
},
},
Expand All @@ -105,177 +121,118 @@ func TestQueryCommitsBranchables_HandlesConcurrentUpdatesAcrossPeerConnection(t
},
},
{
"cid": testUtils.NewUniqueCid("collection, node0 update1"),
"cid": testUtils.NewUniqueCid("collection, update2"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("collection, create"),
"cid": testUtils.NewUniqueCid("collection, node0 update1"),
},
{
"cid": testUtils.NewUniqueCid("doc, node0 update1"),
},
},
},
{
"cid": testUtils.NewUniqueCid("name, node0 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, create"),
"cid": testUtils.NewUniqueCid("doc, update2"),
},
},
},
{
"cid": testUtils.NewUniqueCid("name, create"),
"links": []map[string]any{},
},
{
"cid": testUtils.NewUniqueCid("name, update2"),
"cid": testUtils.NewUniqueCid("collection, node0 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, node1 update1"),
"cid": testUtils.NewUniqueCid("collection, create"),
},
},
},
{
"cid": testUtils.NewUniqueCid("name, node1 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, create"),
"cid": testUtils.NewUniqueCid("doc, node0 update1"),
},
},
},
{
"cid": testUtils.NewUniqueCid("doc, update2"),
"cid": testUtils.NewUniqueCid("name, update3"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("doc, node1 update1"),
"cid": testUtils.NewUniqueCid("name, node1 update1"),
},
{
"cid": testUtils.NewUniqueCid("name, update2"),
},
},
},
{
"cid": testUtils.NewUniqueCid("doc, node1 update1"),
"cid": testUtils.NewUniqueCid("name, update2"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("doc, create"),
},
{
"cid": testUtils.NewUniqueCid("name, node1 update1"),
"cid": testUtils.NewUniqueCid("name, node0 update1"),
},
},
},
{
"cid": testUtils.NewUniqueCid("doc, create"),
"cid": testUtils.NewUniqueCid("name, node0 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, create"),
},
},
},
{
"cid": testUtils.NewUniqueCid("doc, node0 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("doc, create"),
},
{
"cid": testUtils.NewUniqueCid("name, node0 update1"),
},
},
"cid": testUtils.NewUniqueCid("name, create"),
"links": []map[string]any{},
},
},
},
},
testUtils.Request{
NodeID: immutable.Some(1),
Request: `query {
commits {
cid
links {
cid
}
}
}`,
Results: map[string]any{
"commits": []map[string]any{
{
"cid": testUtils.NewUniqueCid("collection, update2"),
"cid": testUtils.NewUniqueCid("name, node1 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("collection, node1 update1"),
},
{
"cid": testUtils.NewUniqueCid("doc, update2"),
"cid": testUtils.NewUniqueCid("name, create"),
},
},
},
{
"cid": testUtils.NewUniqueCid("collection, node1 update1"),
"cid": testUtils.NewUniqueCid("doc, update3"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("collection, create"),
"cid": testUtils.NewUniqueCid("doc, update2"),
},
{
"cid": testUtils.NewUniqueCid("doc, node1 update1"),
},
{
"cid": testUtils.NewUniqueCid("name, update3"),
},
},
},
{
"cid": testUtils.NewUniqueCid("collection, create"),
"cid": testUtils.NewUniqueCid("doc, node1 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("doc, create"),
},
},
},
{
"cid": testUtils.NewUniqueCid("name, update2"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, node1 update1"),
},
},
},
{
"cid": testUtils.NewUniqueCid("name, node1 update1"),
"cid": testUtils.NewUniqueCid("doc, create"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, create"),
},
},
},
{
"cid": testUtils.NewUniqueCid("name, create"),
"links": []map[string]any{},
},
{
"cid": testUtils.NewUniqueCid("doc, update2"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("doc, node1 update1"),
"cid": testUtils.NewUniqueCid("doc, node0 update1"),
},
{
"cid": testUtils.NewUniqueCid("name, update2"),
},
},
},
{
"cid": testUtils.NewUniqueCid("doc, node1 update1"),
"cid": testUtils.NewUniqueCid("doc, node0 update1"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("doc, create"),
},
{
"cid": testUtils.NewUniqueCid("name, node1 update1"),
},
},
},
{
"cid": testUtils.NewUniqueCid("doc, create"),
"links": []map[string]any{
{
"cid": testUtils.NewUniqueCid("name, create"),
"cid": testUtils.NewUniqueCid("name, node0 update1"),
},
},
},
Expand All @@ -291,7 +248,7 @@ func TestQueryCommitsBranchables_HandlesConcurrentUpdatesAcrossPeerConnection(t
Results: map[string]any{
"Users": []map[string]any{
{
"name": "Chris",
"name": "Addo",
},
},
},
Expand Down

0 comments on commit c4ab423

Please sign in to comment.