-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
158 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,4 @@ package object api { | |
|
||
val PARENT_UP = "../" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/scala/com/github/fluency03/blockchain/core/Wallet.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.fluency03.blockchain.core | ||
|
||
trait Wallet { | ||
|
||
} | ||
|
||
|
||
|
||
case class RandomWallet() extends Wallet { | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
object RandomWallet { | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
case class SeededWallet() extends Wallet { | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
object SeededWallet { | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/scala/com/github/fluency03/blockchain/core/KeyContainerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.github.fluency03.blockchain | ||
package core | ||
|
||
import com.github.fluency03.blockchain.core.KeyContainer._ | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
import scala.collection.mutable | ||
|
||
class KeyContainerTest extends FlatSpec with Matchers { | ||
|
||
"balanceOfKey" should "obtain the balance of a Key based on UTXOs." in { | ||
val kc = KeyContainer() | ||
val uTxOs: mutable.Map[Outpoint, TxOut] = mutable.Map.empty[Outpoint, TxOut] | ||
|
||
balanceOfKey(kc, uTxOs) shouldEqual 0 | ||
kc.balance(uTxOs) shouldEqual 0 | ||
|
||
uTxOs += (Outpoint("def0", 0) -> TxOut(kc.address, 40)) | ||
uTxOs += (Outpoint("def0", 1) -> TxOut("abc4", 40)) | ||
|
||
balanceOfKey(kc, uTxOs) shouldEqual 40 | ||
kc.balance(uTxOs) shouldEqual 40 | ||
} | ||
|
||
"KeyContainer" should "be able to sign a TxIn." in { | ||
val kc = KeyContainer() | ||
val id = "".toSha256 | ||
val txIn = TxIn(Outpoint("def0", 0), "abc") | ||
val uTxOs: mutable.Map[Outpoint, TxOut] = mutable.Map.empty[Outpoint, TxOut] | ||
|
||
val signedTxIn0 = kc.sign(id, txIn, uTxOs) | ||
signedTxIn0 shouldEqual None | ||
|
||
uTxOs += (Outpoint("def0", 0) -> TxOut(kc.address, 40)) | ||
uTxOs += (Outpoint("def0", 1) -> TxOut("abc4", 40)) | ||
|
||
val signedTxIn = kc.sign(id, txIn, uTxOs) | ||
signedTxIn shouldEqual Some(TxIn(Outpoint("def0", 0), signedTxIn.get.signature)) | ||
} | ||
|
||
|
||
} |
43 changes: 0 additions & 43 deletions
43
src/test/scala/com/github/fluency03/blockchain/core/SingleWalletTest.scala
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
src/test/scala/com/github/fluency03/blockchain/core/WalletTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.github.fluency03.blockchain.core | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
class WalletTest extends FlatSpec with Matchers { | ||
|
||
"Wallet" should "do something." in { | ||
|
||
} | ||
|
||
} |