Check .dup state when Stateful

master
Didactic Drunk 2021-06-16 19:47:38 -07:00
parent 0b966714b6
commit 53b44e6ecd
3 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,11 @@
module Crypto
module Secret
module Stateless
end
module Stateful
end
end
end
require "crypto/subtle"

View File

@ -66,7 +66,9 @@ module Crypto::Secret
end
# WARNING: Not thread safe
private def set_state(new_state : State)
# Kept public for .dup
# :nodoc:
def set_state(new_state : State)
return if @state == new_state
case new_state

View File

@ -56,9 +56,11 @@ macro test_secret_class(to sclass)
secret1 = sclass.copy_from key
secret2 = secret1.dup
(secret1 == secret2).should be_true
end
pending "check dup state" { }
if secret1.is_a?(Crypto::Secret::Stateful) && secret2.is_a?(Crypto::Secret::Stateful)
secret1.@state.should eq secret2.@state
end
end
it "bytesize" do
secret = sclass.new 5