You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
840 B

using Random
## CREATE
FDBNAME = "test1"
FILEDB = open(FDBNAME, "w")
# create 100 users
unum = 100
users = []
uuids = UUID.(1:unum)
for uuid in uuids
u = User(provider, "Nicolò", "Balzarotti", "3935027690", nothing,
"\$argon2id\$v=19\$m=65536,t=2,p=1\$c1FCl+2ur/YcMwcfNCsBkw\$xqCwQ/VeJNTkrEduNO7SyhQSDSW5hJMxjBaBFpIr26Q",
false, false, false, uuid, 0)
push!(users, u)
end
for user in users
write(FILEDB, Action(create, user))
end
# Randomly modify those users
for i in 1:100_000
u = rand(users)
u.online = rand(Bool)
u.version += 1
write(FILEDB, Action(modify, u))
end
# Delete half of them
todelete = users[randperm(length(users))][1:(length(users) ÷ 2)]
for u in todelete
write(FILEDB, Action(delete, u))
end
close(FILEDB)
x = restore(FDBNAME, User)
InMemoryLoggedDB.replay(x)