From 2d1ba481d8d4a3621e1d81950e5d32b728ae5bc3 Mon Sep 17 00:00:00 2001 From: Ashy5000 Date: Mon, 1 Apr 2024 10:14:54 -0700 Subject: [PATCH] Implements testing for security.go --- security_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 security_test.go diff --git a/security_test.go b/security_test.go new file mode 100644 index 0000000..dc83208 --- /dev/null +++ b/security_test.go @@ -0,0 +1,28 @@ +package main + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestApplySecurityLevel(t *testing.T) { + t.Run("It sets the correct parameters for security level 0", func(t *testing.T) { + ApplySecurityLevel(0) + assert.Equal(t, initialBlockDifficulty, securityLevels[0].InitialBlockDifficulty) + assert.Equal(t, minimumBlockDifficulty, securityLevels[0].MinimumDifficulty) + assert.Equal(t, blocksBeforeSpendable, securityLevels[0].BlocksBeforeSpendable) + }) + t.Run("It sets the correct parameters for security level 1", func(t *testing.T) { + ApplySecurityLevel(1) + assert.Equal(t, initialBlockDifficulty, securityLevels[1].InitialBlockDifficulty) + assert.Equal(t, minimumBlockDifficulty, securityLevels[1].MinimumDifficulty) + assert.Equal(t, blocksBeforeSpendable, securityLevels[1].BlocksBeforeSpendable) + }) + t.Run("It sets the correct parameters for security level 2", func(t *testing.T) { + ApplySecurityLevel(2) + assert.Equal(t, initialBlockDifficulty, securityLevels[2].InitialBlockDifficulty) + assert.Equal(t, minimumBlockDifficulty, securityLevels[2].MinimumDifficulty) + assert.Equal(t, blocksBeforeSpendable, securityLevels[2].BlocksBeforeSpendable) + }) +}