Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Jul 10, 2024
1 parent a2011a4 commit 02a888c
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions lib/journal/fsjournal/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
package fsjournal

import (
"encoding/json"
"os"
"path/filepath"
"testing"
"time"

"github.com/ipfs-force-community/sophon-miner/lib/journal"
"github.com/ipfs-force-community/sophon-miner/node/repo"
Expand Down Expand Up @@ -45,37 +43,4 @@ func TestFsJournal(t *testing.T) {
require.Error(t, err)
require.NoError(t, os.RemoveAll(dir))
}

{
// stm: @VENUSMINER_FSJOURNAL_OPEN_FS_JOURNAL_001
jl, err := OpenFSJournal(lr, envDisableEvent)
require.NoError(t, err)

eType := jl.RegisterEventType("s1", "b1")
require.NoError(t, err)

// stm: @VENUSMINER_FSJOURNAL_RECORD_EVENT_001
jl.RecordEvent(eType, func() interface{} {
return "hello"
})

t.Logf("Waiting record event...")
t.Logf("dir: %s, lr.Path(): %s", dir, lr.Path())

time.AfterFunc(time.Millisecond*500, func() {
recordEventData, err := os.ReadFile(jlFile)
require.NoError(t, err)

event := &journal.Event{}
require.NoErrorf(t, json.Unmarshal(recordEventData, event),
"json unmarshal: [%s] to journal.Event failed.", string(recordEventData))
if message, isok := event.Data.(string); !isok {
t.Errorf("event.Data should be a string")
} else {
require.Equal(t, message, "hello")
}
})

require.NoError(t, jl.Close())
}
}

0 comments on commit 02a888c

Please sign in to comment.