Documentation ¶
Index ¶
- Constants
- Variables
- func AwardDescriptors(reactions []tp.Reaction) []tp.Reaction
- func CheckDescriptor(descriptor, descriptors string) bool
- func GenerateRawPasscode() string
- func GetTagColour(tag int) string
- func GetTimestring(moment time.Time) string
- func Pkcs5Padding(ciphertext []byte, blockSize int, after int) []byte
- func Pkcs5Trimming(encrypt []byte) []byte
- func TimeSincePost(isDays bool, lastPostTime time.Time) int
- func ValidateHashTiming(lastPostTime time.Time, hashIndex int) bool
- func ValidateInputLength(p tp.Post) bool
- type MockController
- func (mc *MockController) Clear() bool
- func (mc *MockController) Init() error
- func (mc *MockController) InsertHash(hash string) error
- func (mc *MockController) InsertPost(post tp.Post) error
- func (mc *MockController) InsertReaction(reaction tp.Reaction) error
- func (mc *MockController) SelectAnonReactionCount(postId int) (int, error)
- func (mc *MockController) SelectCandidateHashes() ([5]string, error)
- func (mc *MockController) SelectDescriptors(postId int) (string, error)
- func (mc *MockController) SelectLatestTimestamp() (time.Time, error)
- func (mc *MockController) SelectPostReactionHashes(postId int) ([5]string, error)
- func (mc *MockController) SelectPostReactions(postId int) ([]tp.Reaction, error)
- func (mc *MockController) SelectPosts() ([]tp.Post, error)
Constants ¶
View Source
const ( HOURS_INT = 3600 // 1 hour in seconds DAYS_INT = 86400 // 1 day in seconds )
Variables ¶
View Source
var ( MockPost = tp.Post{ Id: 1, Title: "test", Author: "tester", Contents: "test contents", Tag: 0, Descriptors: "test;experimental;mocking", Time: generateMockTime(), } MockReaction = tp.Reaction{ Id: 1, PostId: 1, Descriptor: "experimental", Gravitas: 6, } MockReaction2 = tp.Reaction{ Id: 2, PostId: 1, Descriptor: "mocking", Gravitas: 4, } MockHashes = [5]string{ "UNUSEDc1884c7659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a09a", "PREVIOUS8184c7d659a2feaa0c55ad015a3bf4f1b2b0b82215d6c15b0f00a08a", "PENULTIMATE4c7d659a2feaa0c55ad015a3bf4f1b2b0b82215d6c15b0f00a0aa", "THIRDccc84c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0ba", "GENESISccc87d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0ba"} InvalidMockHashes = [3]string{ "INVALIDc884c7659a2feaa0c55ad015a3bf4f1b2b0b822cd1a5d6c15b0f00a09", "ffa88d265a882b0716c60227e9ddb5c6a09542ec9b40b875463908a760ed0d6f", ""} TestPosts = [7]tp.Post{ { Title: "test genesis post", Author: "God", Contents: `In the beginning God created the heavens and earth`, Tag: 0, Descriptors: "please overwrite me", }, { Title: "test first post", Author: "welcomebot", Contents: `Robots are cool`, Tag: 7, Descriptors: "please overwrite me", }, { Title: "test second post", Author: "g yang", Contents: `do not worry child`, Tag: 4, }, { Title: "test 3 post", Author: "welcomebot", Contents: `#ethereum`, Tag: 1, }, { Title: "test 4 post", Author: "g yang", Contents: `boris out`, Tag: 6, }, { Title: "test 5 post", Author: "dommedman", Contents: `orange pill`, Tag: 2, }, { Title: "test 6 post", Author: "shapiro", Contents: "squeak, squeak", Tag: 5, }, } TestInvalidPosts = [3]tp.Post{ { Title: "test genesis post", Author: "God", Contents: `this post has a duplicate title`, Tag: 0, Descriptors: "please overwrite me", }, { Title: "test other post 5", Author: "author length than 10 chars", Contents: `In the beginning God created the heavens and earth`, Tag: 0, Descriptors: "please overwrite me", }, { Title: "test other post 6", Author: "anon", Contents: "this post has no tag", Descriptors: "please overwrite me", }, } )
Data to populate this mock controller
Functions ¶
func AwardDescriptors ¶
Returns and adds colour to the top 3 descriptors
func CheckDescriptor ¶
Checks if the descriptor is in the descriptors string
func GenerateRawPasscode ¶
func GenerateRawPasscode() string
Generates a new plain-text to lead the chain, that is moderately secure
in plaintext
func GetTimestring ¶
Gets a UI suitable time for the post
func Pkcs5Padding ¶
Boilerplate padding function
func TimeSincePost ¶
Gets the days since last post as int
func ValidateHashTiming ¶
Validates if the provided hash index has the authority to make a post at
this time
func ValidateInputLength ¶
Validates length of post input fields
Types ¶
type MockController ¶
type MockController struct{}
Mock database controller, used by all unit tests
func (*MockController) InsertHash ¶
func (mc *MockController) InsertHash(hash string) error
Mock method implementation
func (*MockController) InsertPost ¶
func (mc *MockController) InsertPost(post tp.Post) error
Mock method implementation
func (*MockController) InsertReaction ¶
func (mc *MockController) InsertReaction(reaction tp.Reaction) error
Mock method implementation
func (*MockController) SelectAnonReactionCount ¶
func (mc *MockController) SelectAnonReactionCount(postId int) (int, error)
Mock method implementation
func (*MockController) SelectCandidateHashes ¶
func (mc *MockController) SelectCandidateHashes() ([5]string, error)
Mock method implementation
func (*MockController) SelectDescriptors ¶
func (mc *MockController) SelectDescriptors(postId int) (string, error)
Mock method implementation
func (*MockController) SelectLatestTimestamp ¶
func (mc *MockController) SelectLatestTimestamp() (time.Time, error)
Mock method implementation
func (*MockController) SelectPostReactionHashes ¶
func (mc *MockController) SelectPostReactionHashes( postId int) ([5]string, error)
Mock method implementation
func (*MockController) SelectPostReactions ¶
func (mc *MockController) SelectPostReactions( postId int) ([]tp.Reaction, error)
Mock method implementation
func (*MockController) SelectPosts ¶
func (mc *MockController) SelectPosts() ([]tp.Post, error)
Mock method implementation
Click to show internal directories.
Click to hide internal directories.