#include "zcash/Address.hpp"
#include "zcash/Note.hpp"
+#include "amount.h"
+#include "random.h"
#include "librustzcash.h"
#include <array>
// Test commitment
SaplingNote note = SaplingNote(diversifier, pk_d, v, r);
- ASSERT_EQ(note.cm(), cm);
+ ASSERT_EQ(note.cm().get(), cm);
// Test nullifier
SaplingSpendingKey spendingKey(sk);
- ASSERT_EQ(note.nullifier(spendingKey, note_pos), nf);
+ ASSERT_EQ(note.nullifier(spendingKey.full_viewing_key(), note_pos), nf);
}
TEST(SaplingNote, Random)
{
- // Test creating random notes using the same sk
- auto sk = SaplingSpendingKey::random();
- SaplingNote note1 = SaplingNote::random(sk);
- SaplingNote note2 = SaplingNote::random(sk);
+ // Test creating random notes using the same spending key
+ auto address = SaplingSpendingKey::random().default_address();
+ SaplingNote note1(address, GetRand(MAX_MONEY));
+ SaplingNote note2(address, GetRand(MAX_MONEY));
ASSERT_EQ(note1.d, note2.d);
ASSERT_EQ(note1.pk_d, note2.pk_d);
ASSERT_NE(note1.r, note2.r);
// Test diversifier and pk_d are not the same for different spending keys
- sk = SaplingSpendingKey::random();
- SaplingNote note3 = SaplingNote::random(sk);
+ SaplingNote note3(SaplingSpendingKey::random().default_address(), GetRand(MAX_MONEY));
ASSERT_NE(note1.d, note3.d);
ASSERT_NE(note1.pk_d, note3.pk_d);
}