Skip to content

Commit a8442bf

Browse files
auto commit
1 parent bde2f78 commit a8442bf

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

TestVectors/dafny/DDBEncryption/src/TestVectors.dfy

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
209209
var res := client.DeleteTable(DDB.DeleteTableInput(TableName := TableName));
210210
}
211211

212+
method SetupTestTable(writeConfig : TableConfig, readConfig : TableConfig)
213+
returns (wClient : DDB.IDynamoDBClient, rClient : DDB.IDynamoDBClient)
214+
ensures wClient.ValidState() && rClient.ValidState()
215+
ensures fresh(wClient) && fresh(wClient.Modifies)
216+
ensures fresh(rClient) && fresh(rClient.Modifies)
217+
{
218+
wClient :- expect newGazelle(writeConfig);
219+
rClient :- expect newGazelle(readConfig);
220+
DeleteTable(wClient);
221+
var _ :- expect wClient.CreateTable(schemaOnEncrypt);
222+
}
223+
212224
function GetUsed(q : SimpleQuery) : (DDB.ExpressionAttributeNameMap, DDB.ExpressionAttributeValueMap)
213225
{
214226
TrimMaps(q.keyExpr.UnwrapOr(""), q.filterExpr.UnwrapOr(""), names, values)
@@ -741,10 +753,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
741753

742754
method BasicIoTestBatchWriteItem(writeConfig : TableConfig, readConfig : TableConfig, records : seq<Record>)
743755
{
744-
var wClient :- expect newGazelle(writeConfig);
745-
var rClient :- expect newGazelle(readConfig);
746-
DeleteTable(wClient);
747-
var _ :- expect wClient.CreateTable(schemaOnEncrypt);
756+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
748757
var i := 0;
749758
while i < |records| {
750759
var count := 10;
@@ -780,10 +789,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
780789

781790
method BasicIoTestTransactWriteItems(writeConfig : TableConfig, readConfig : TableConfig, records : seq<Record>)
782791
{
783-
var wClient :- expect newGazelle(writeConfig);
784-
var rClient :- expect newGazelle(readConfig);
785-
DeleteTable(wClient);
786-
var _ :- expect wClient.CreateTable(schemaOnEncrypt);
792+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
787793
var i := 0;
788794
while i < |records| {
789795
var count := 10;
@@ -839,10 +845,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
839845

840846
method BasicIoTestExecuteStatement(writeConfig : TableConfig, readConfig : TableConfig)
841847
{
842-
var wClient :- expect newGazelle(writeConfig);
843-
var rClient :- expect newGazelle(readConfig);
844-
DeleteTable(wClient);
845-
var _ :- expect wClient.CreateTable(schemaOnEncrypt);
848+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
846849

847850
// Create a PartiQL INSERT statement
848851
// The dynamodb attributes are random and non-existent because ExecuteStatement is supposed to be failed before going into dynamodb.
@@ -883,10 +886,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
883886

884887
method BasicIoTestExecuteTransaction(writeConfig : TableConfig, readConfig : TableConfig)
885888
{
886-
var wClient :- expect newGazelle(writeConfig);
887-
var rClient :- expect newGazelle(readConfig);
888-
DeleteTable(wClient);
889-
var _ :- expect wClient.CreateTable(schemaOnEncrypt);
889+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
890890

891891
// Create a PartiQL transaction with INSERT and SELECT statements
892892
// The dynamodb attributes are random and non-existent because ExecuteTransaction is supposed to fail before going to dynamodb
@@ -925,10 +925,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
925925

926926
method BasicIoTestBatchExecuteStatement(writeConfig : TableConfig, readConfig : TableConfig)
927927
{
928-
var wClient :- expect newGazelle(writeConfig);
929-
var rClient :- expect newGazelle(readConfig);
930-
DeleteTable(wClient);
931-
var _ :- expect wClient.CreateTable(schemaOnEncrypt);
928+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
932929

933930
// Create a batch of PartiQL statements
934931
// The dynamodb attributes are random and non-existent because BatchExecuteStatement is supposed to fail before going into dynamodb

0 commit comments

Comments
 (0)