From 0f2de6394a1c52d47e326bb7d7d129a217ae4f6f Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 10 Aug 2021 13:32:39 +0200 Subject: Dereference remote replies (#132) * decided where to put reply dereferencing * fiddling with dereferencing threads * further adventures * tidy up some stuff * move dereferencing functionality * a bunch of refactoring * go fmt * more refactoring * bleep bloop * docs and linting * start implementing replies collection on gts side * fiddling around * allow dereferencing our replies * lint, fmt --- testrig/db.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'testrig/db.go') diff --git a/testrig/db.go b/testrig/db.go index 01cf93934..fe38c3164 100644 --- a/testrig/db.go +++ b/testrig/db.go @@ -65,7 +65,14 @@ func NewTestDB() db.DB { } // StandardDBSetup populates a given db with all the necessary tables/models for perfoming tests. -func StandardDBSetup(db db.DB) { +// +// The accounts parameter is provided in case the db should be populated with a certain set of accounts. +// If accounts is nil, then the standard test accounts will be used. +// +// When testing http signatures, you should pass into this function the same accounts map that you generated +// signatures with, otherwise this function will randomly generate new keys for accounts and signature +// verification will fail. +func StandardDBSetup(db db.DB, accounts map[string]*gtsmodel.Account) { for _, m := range testModels { if err := db.CreateTable(m); err != nil { panic(err) @@ -96,9 +103,17 @@ func StandardDBSetup(db db.DB) { } } - for _, v := range NewTestAccounts() { - if err := db.Put(v); err != nil { - panic(err) + if accounts == nil { + for _, v := range NewTestAccounts() { + if err := db.Put(v); err != nil { + panic(err) + } + } + } else { + for _, v := range accounts { + if err := db.Put(v); err != nil { + panic(err) + } } } -- cgit v1.2.3