mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
contract/test-harness: Use deterministic genesis coin and keypairs.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
use darkfi::{tx::Transaction, Result};
|
||||
use darkfi::{tx::Transaction, zk::halo2::Field, Result};
|
||||
use darkfi_consensus_contract::{
|
||||
client::genesis_stake_v1::ConsensusGenesisStakeCallBuilder,
|
||||
model::ConsensusGenesisStakeParamsV1, ConsensusFunction,
|
||||
@@ -26,6 +26,7 @@ use darkfi_consensus_contract::{
|
||||
use darkfi_money_contract::CONSENSUS_CONTRACT_ZKAS_MINT_NS_V1;
|
||||
use darkfi_sdk::{
|
||||
crypto::{MerkleNode, CONSENSUS_CONTRACT_ID},
|
||||
pasta::pallas,
|
||||
ContractCall,
|
||||
};
|
||||
use darkfi_serial::{serialize, Encodable};
|
||||
@@ -54,7 +55,13 @@ impl TestHarness {
|
||||
mint_zkbin: mint_zkbin.clone(),
|
||||
mint_pk: mint_pk.clone(),
|
||||
}
|
||||
.build()?;
|
||||
.build_with_params(
|
||||
pallas::Scalar::random(&mut OsRng),
|
||||
pallas::Scalar::random(&mut OsRng),
|
||||
pallas::Scalar::random(&mut OsRng),
|
||||
pallas::Base::from(28),
|
||||
)?;
|
||||
|
||||
let (genesis_stake_params, genesis_stake_proofs) =
|
||||
(genesis_stake_call_debris.params, genesis_stake_call_debris.proofs);
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ use std::collections::HashMap;
|
||||
use darkfi::{
|
||||
blockchain::BlockInfo,
|
||||
runtime::vm_runtime::SMART_CONTRACT_ZKAS_DB_NAME,
|
||||
util::time::TimeKeeper,
|
||||
util::{
|
||||
pcg::Pcg32,
|
||||
time::{TimeKeeper, Timestamp},
|
||||
},
|
||||
validator::{Validator, ValidatorConfig, ValidatorPtr},
|
||||
wallet::{WalletDb, WalletPtr},
|
||||
zk::{empty_witnesses, ProvingKey, ZkCircuit},
|
||||
@@ -209,30 +212,34 @@ pub struct TestHarness {
|
||||
impl TestHarness {
|
||||
pub async fn new(contracts: &[String]) -> Result<Self> {
|
||||
let mut holders = HashMap::new();
|
||||
let genesis_block = BlockInfo::default();
|
||||
let mut genesis_block = BlockInfo::default();
|
||||
genesis_block.header.timestamp = Timestamp(1689772567);
|
||||
|
||||
let faucet_kp = Keypair::random(&mut OsRng);
|
||||
// Deterministic PRNG
|
||||
let mut rng = Pcg32::new(42);
|
||||
|
||||
let faucet_kp = Keypair::random(&mut rng);
|
||||
let faucet_pubkeys = vec![faucet_kp.public];
|
||||
let faucet = Wallet::new(faucet_kp, &genesis_block, &faucet_pubkeys).await?;
|
||||
holders.insert(Holder::Faucet, faucet);
|
||||
|
||||
let alice_kp = Keypair::random(&mut OsRng);
|
||||
let alice_kp = Keypair::random(&mut rng);
|
||||
let alice = Wallet::new(alice_kp, &genesis_block, &faucet_pubkeys).await?;
|
||||
// Alice is inserted at end of function
|
||||
|
||||
let bob_kp = Keypair::random(&mut OsRng);
|
||||
let bob_kp = Keypair::random(&mut rng);
|
||||
let bob = Wallet::new(bob_kp, &genesis_block, &faucet_pubkeys).await?;
|
||||
holders.insert(Holder::Bob, bob);
|
||||
|
||||
let charlie_kp = Keypair::random(&mut OsRng);
|
||||
let charlie_kp = Keypair::random(&mut rng);
|
||||
let charlie = Wallet::new(charlie_kp, &genesis_block, &faucet_pubkeys).await?;
|
||||
holders.insert(Holder::Charlie, charlie);
|
||||
|
||||
let rachel_kp = Keypair::random(&mut OsRng);
|
||||
let rachel_kp = Keypair::random(&mut rng);
|
||||
let rachel = Wallet::new(rachel_kp, &genesis_block, &faucet_pubkeys).await?;
|
||||
holders.insert(Holder::Rachel, rachel);
|
||||
|
||||
let dao_kp = Keypair::random(&mut OsRng);
|
||||
let dao_kp = Keypair::random(&mut rng);
|
||||
let dao = Wallet::new(dao_kp, &genesis_block, &faucet_pubkeys).await?;
|
||||
holders.insert(Holder::Dao, dao);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user